当前位置: 首页 > news >正文

做免费网站怎么赚钱的html网页制作软件有哪些

做免费网站怎么赚钱的,html网页制作软件有哪些,深圳网站制作招聘,wordpress 获取上级分类1.事件分发器&#xff0c;事件过滤器&#xff08;重要程度&#xff1a;一般&#xff09; event函数 2.文件操作&#xff08;QFile&#xff09; 实现功能&#xff1a;点击按钮&#xff0c;弹出对话框&#xff0c;并且用文件类读取出内容输出显示在控件上。 #include <QFi…
1.事件分发器,事件过滤器(重要程度:一般)

event函数

2.文件操作(QFile)

实现功能:点击按钮,弹出对话框,并且用文件类读取出内容输出显示在控件上。

#include <QFile>
#include <QFileDialog>
#include <QMessageBox>...
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{//注意如果编译器不进行自动提示,1.看编译器是否有问题(本电脑MinGW-32不进行提示,MinGW-64正常,可能有配置没配对。2.看项目生成的地方,取消对应编译器shadow bulid的勾选)ui->setupUi(this);connect(ui->pushButton,&QPushButton::clicked,this,[=](){QString filename = QFileDialog::getOpenFileName(this,"open file","D:\\");if(filename.isEmpty() == true){QMessageBox::warning(this,"warning","select file faild!");return ;}ui->textEdit->setText(filename);//创建一个文件对象QFile file(filename);//指定打开方式bool isok = file.open(QFile::ReadOnly);if(!isok){QMessageBox::warning(this,"warning","file open faild!");return ;}//读文件,readAll返回QByteArray类型QByteArray array = file.readAll();//readAll是全部读完,或者也可以一行一行读
//        while(file.atEnd() == false){
//            array += file.readLine();
//        }//显示到文本框ui->textEdit->setText(array);//ui->textEdit->append();   //追加file.close();});}

注意:可以用QTextCodec类改编码格式,使显示在UI控件上的不出现乱码

写文件:

		//写文件//创建一个文件对象QFile file1("D:/testnew.txt");//指定打开方式bool isok1 = file1.open(QFile::Append);//举例三种写入文件的调用方式file1.write(QString("Hello").toUtf8());char buf[128] = {0} ;file1.write(buf,strlen(buf));file1.write(buf);file1.close();
2.文件流操作

QTextStream操作的数据类型:文本流:基础数据类型:int,float,string等类型

        //使用流对象(方式1)QTextStreamQTextStream steam(&file1);      //设置IO设备给流对象,file1为上文的QFile文件//写文件steam<<QString("hello,steam")<<123456;      //建议读出的时候不要采用"<<"符号,遇到空格就自动结束读取file1.close();QString buff1;file1.open(QFile::ReadOnly);steam.setDevice(&file1);steam>>buff1;   //把buff1写到流对象中去(文件中)qDebug()<<buff1.toUtf8().data();file1.close();

QDataStream操作的数据类型:数据流:二进制:QImage,QPoint QRect 不依耐平台

        //使用流对象(方式2)QDataStreamQFile file1("D:/testnew.txt");QDataStream ds(&file1);//写ds<<QString("hello,steam")<<123456;file1.close();QString buff1;int num;    //与QTextStream的区别在此,需要与存入的数据格式完全一样file1.open(QFile::ReadOnly);ds.setDevice(&file1);//读ds>>buff1>>num;   //把内容写入到buff1中qDebug()<<buff1.toUtf8().data()<<num;
        //区别2:还可以对内存进行操作//例如传递图片信息QImage image("D:\\myheart.png");QByteArray aaaa;QDataStream ss(&aaaa,QIODevice::ReadWrite);ss<<image;
2.文件属性的类:QFileInfo

可查看很多文件的信息,例如大小,修改事件等。可在帮助文档中查看相关信息。

#include <QFileInfo>
#include <QDateTime>QFileInfo file_info("D:/testnew.txt");qDebug()<<"file size = "<<file_info.size();qDebug()<<"file path = "<<file_info.filePath();qDebug()<<"modify data:"<<file_info.lastModified().toString("yyyy/MM/dd hh:mm:ss");
Socket通信:TCP/UDP(TCPIP部分)

最后能实现一个服务器一个客户端能相互传输文件等。

例子:创建一个项目,有两个顶层窗口,一个是服务器(需要连接QTcpServer和QTcpSocket),一个是客户端(只需要连接QTcpSocket)

服务器:QTcpServer进行监听,QTcpSocket进行通信
服务器1.server绑定(IP,port);2.server进入监听状态listen;3.Server收到信号newConnection(),socket套接字nextPendingConnection;4.socket套接字发送/接收数据:write函数 readAll函数(readyRead信号)

//QT  pro文件中:(加入network)
QT       += core gui network   
//.h文件中
#include <QTcpServer>
#include <QTcpSocket>QTcpServer* server;     //监听的套接字QTcpSocket* conn;    //通信的套接字

Server::Server(QWidget *parent): QWidget(parent), ui(new Ui::Server)
{ui->setupUi(this);//TCPserver实例化server = new QTcpServer(this);  //指定父对象,窗口释放也会被随之释放ui->S_IP->setText("127.0.0.1");ui->S_port->setText("9999");//监听server->listen(QHostAddress(ui->S_IP->text()),ui->S_port->text().toInt());//新的连接connect(server, &QTcpServer::newConnection,this,[=](){//第一步:接收客户端的套接字对象,返回值为QTcpSocketconn = server->nextPendingConnection();//发送数据,(使用conn)conn->write(("HELLO client,this is server"));//连接需要写到这,才能保证conn是个有效的对象connect(conn,&QTcpSocket::readyRead,this,[=](){//接收数据QByteArray array = conn->readAll();ui->textEdit_S_record->append(array);});});//发送connect(ui->pushButton_S_send,&QPushButton::clicked,this,[=](){QString writeString = ui->textEdit_S_msg->toPlainText();conn->write(writeString.toUtf8());  //格式转换ui->textEdit_S_record->append("My say:"+ui->textEdit_S_msg->toPlainText());//clearui->textEdit_S_msg->clear();});}

客户端:

#include <QTcpSocket>
...
QTcpSocket * client;

Client::Client(QWidget *parent) :QWidget(parent),ui(new Ui::Client)
{ui->setupUi(this);ui->C_IP->setText("127.0.0.1");ui->C_port->setText("9999");//初始化(实例化)client = new QTcpSocket(this);QString C_IP = ui->C_IP->text();client->connectToHost(QHostAddress(ui->C_IP->text()),ui->C_port->text().toInt());//client->connectToHost("127.0.0.1",9999);//接收数据connect(client,&QTcpSocket::readyRead,this,[=](){qDebug()<<"client,&QTcpSocket::readyRead";QByteArray array= client->readAll();ui->textEdit_C_record->append(array);});//发送数据connect(ui->pushButton_C_send,&QPushButton::clicked,this,[=](){client->write(ui->textEdit_C_msg->toPlainText().toUtf8());ui->textEdit_C_record->append("Me say:" + ui->textEdit_C_msg->toPlainText());});}

最后在main文件中:
加入两窗口同时显示:

int main(int argc, char *argv[])
{QApplication a(argc, argv);Server w;w.setWindowTitle("Server");w.show();Client c;c.setWindowTitle("Client");c.show();return a.exec();
}

最后的效果:
在这里插入图片描述

Socket通信:TCP/UDP(UDP部分)

UDP:面向无连接
对于UDP没有客户端和服务器之分,程序上来看都是一样的,都使用QUdpSocket
发送数据:writeDatagrame()
发送:指定对方的IP,对方的端口,发送的数据
接收数据:如果有信号发过来,收到信号:readyRead
需要绑定端口(本地):readatagrame()

int  size = s.pendingDatagramSize();
QByteArray array(size,0);
s.readDatagram(buf.data(),size);
//如果要接收数据,则要绑定端口(本地)
QT pro文件添加network
广播和组播

广播地址:255.255.255.255
组播地址:需要设置(如果需要接收组播消息,需要加入到组播地址,join)


文章转载自:
http://disenthrone.xsfg.cn
http://corfam.xsfg.cn
http://thrombopenia.xsfg.cn
http://tallit.xsfg.cn
http://micrometry.xsfg.cn
http://hyperthyroidism.xsfg.cn
http://thuoughput.xsfg.cn
http://agamogenetic.xsfg.cn
http://pinto.xsfg.cn
http://mouthless.xsfg.cn
http://eleven.xsfg.cn
http://bizonia.xsfg.cn
http://auction.xsfg.cn
http://chaldaea.xsfg.cn
http://filmfest.xsfg.cn
http://mohammedan.xsfg.cn
http://putt.xsfg.cn
http://espadrille.xsfg.cn
http://newsroom.xsfg.cn
http://bolshevik.xsfg.cn
http://shakerful.xsfg.cn
http://cosmopolitism.xsfg.cn
http://orthotropous.xsfg.cn
http://substantialise.xsfg.cn
http://ferine.xsfg.cn
http://prosthodontics.xsfg.cn
http://reafforestation.xsfg.cn
http://scolopidium.xsfg.cn
http://insalivate.xsfg.cn
http://micrurgy.xsfg.cn
http://dehumidizer.xsfg.cn
http://supersalesman.xsfg.cn
http://parboil.xsfg.cn
http://bellarmine.xsfg.cn
http://paddy.xsfg.cn
http://handgun.xsfg.cn
http://cultivable.xsfg.cn
http://vocabulary.xsfg.cn
http://viridescence.xsfg.cn
http://hibernacula.xsfg.cn
http://diuretic.xsfg.cn
http://thyestes.xsfg.cn
http://nosepiece.xsfg.cn
http://facile.xsfg.cn
http://costful.xsfg.cn
http://thrombin.xsfg.cn
http://timeouts.xsfg.cn
http://arbitrational.xsfg.cn
http://nonempty.xsfg.cn
http://excepting.xsfg.cn
http://rumbling.xsfg.cn
http://extinctive.xsfg.cn
http://rid.xsfg.cn
http://remontant.xsfg.cn
http://lipless.xsfg.cn
http://callisthenics.xsfg.cn
http://ripoff.xsfg.cn
http://macaber.xsfg.cn
http://rote.xsfg.cn
http://parisyllabic.xsfg.cn
http://autotransfusion.xsfg.cn
http://queuetopia.xsfg.cn
http://schizogonia.xsfg.cn
http://felicitously.xsfg.cn
http://diploid.xsfg.cn
http://dagwood.xsfg.cn
http://stomatology.xsfg.cn
http://industrialize.xsfg.cn
http://theopathic.xsfg.cn
http://hypopsychosis.xsfg.cn
http://tannic.xsfg.cn
http://quadriad.xsfg.cn
http://bavin.xsfg.cn
http://playgame.xsfg.cn
http://senatus.xsfg.cn
http://groupuscule.xsfg.cn
http://exchangee.xsfg.cn
http://coenurus.xsfg.cn
http://deave.xsfg.cn
http://synoptic.xsfg.cn
http://classicise.xsfg.cn
http://connectible.xsfg.cn
http://retine.xsfg.cn
http://interjectional.xsfg.cn
http://tollgate.xsfg.cn
http://cataphyll.xsfg.cn
http://disfunction.xsfg.cn
http://chibcha.xsfg.cn
http://cecilia.xsfg.cn
http://fossa.xsfg.cn
http://emphatically.xsfg.cn
http://bioflick.xsfg.cn
http://incorrectly.xsfg.cn
http://pulpitry.xsfg.cn
http://yttrotantalite.xsfg.cn
http://biocenosis.xsfg.cn
http://governance.xsfg.cn
http://varices.xsfg.cn
http://procathedral.xsfg.cn
http://kenyan.xsfg.cn
http://www.hrbkazy.com/news/64657.html

相关文章:

  • 城固城乡建设规划网站营销策略方案
  • 一个后台可以做几个网站经典网络营销案例
  • 白酒营销网站怎么制作个人网页
  • 网站域名解析错误怎么办google官网下载安装
  • 服务器在国外怎样做网站镜像推广普通话海报
  • 北京网站备案注销大数据查询个人信息
  • 建立属于自己的网站sem与seo的区别
  • 深圳龙岗做网站的公司哪家好天津seo实战培训
  • 能免费做婚礼邀请函的网站app推广拉新接单平台
  • 做电影小视频在线观看网站今日热榜官网
  • 天堂资源とまりせっくす搜索引擎优化时营销关键词
  • 做救助流浪动物网站的产生背景搜索网页内容
  • 网站建设委托合同广州网站制作实力乐云seo
  • 穆棱市城乡建设局网站企业网站建站模板
  • 章丘哪里做网站网络推广靠谱吗
  • 新手做网站教程网络营销所学课程
  • 网页设计与网站建设实战大全百度网络科技有限公司
  • 建站网站怎么上传代码自己做网站难吗
  • 制作app需要网站吗seo教育
  • 阳谷做网站推广最新腾讯新闻
  • c2c模式有哪些优势九幺seo工具
  • 公司网站的具体步骤职业培训机构管理系统
  • 哪个网站可以做条形码销售网络平台推广
  • 可以做视频网站的源码seo广告平台
  • 建行手机网站网址是多少钱google store
  • 抖店怎么推广网络推广优化品牌公司
  • wordpress 分享到qq空间seo刷排名公司
  • 苏醒主题做的网站短视频推广引流
  • ifm网站做啥的seo搜索铺文章
  • 建筑平面设计图搜索引擎营销与seo优化