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

ppt模板下载的网站有哪些岳阳公司做网站

ppt模板下载的网站有哪些,岳阳公司做网站,广州调查公司,交易链接该示例演示了在本地主机上的TCP客户端和服务器是如何通讯的。客户端 绑定信号槽。connect(tcpClient, QAbstractSocket::connected, this, Dialog::startTransfer); /* 连接到服务器时回送消息给服务器 */ connect(tcpClient, QIODevice::bytesWritte…该示例演示了在本地主机上的TCP客户端和服务器是如何通讯的。客户端 绑定信号槽。connect(tcpClient, QAbstractSocket::connected, this, Dialog::startTransfer); /* 连接到服务器时回送消息给服务器 */ connect(tcpClient, QIODevice::bytesWritten,this, Dialog::updateClientProgress); /* 绑定写数据到服务器的信号槽 */连接到服务器。tcpClient.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());这里比较有意思的是客户端连接到服务器-客户端(tcpClient)触发startTransfer槽函数-调用tcpClient.write-触发QIODevice::bytesWritten信号-触发updateClientProgress槽函数调用-就一直tcpClient.write直到if条件不成立后后停止发送。void Dialog::startTransfer() {// called when the TCP client connected to the loopback serverbytesToWrite TotalBytes - int(tcpClient.write(QByteArray(PayloadSize, )));clientStatusLabel-setText(tr(Connected)); } void Dialog::updateClientProgress(qint64 numBytes) {// called when the TCP client has written some bytesbytesWritten int(numBytes);// only write more if not finished and when the Qt write buffer is below a certain size.if (bytesToWrite 0 tcpClient.bytesToWrite() 4 * PayloadSize) /* 直到if条件不成立后后停止发送 */bytesToWrite - tcpClient.write(QByteArray(qMin(bytesToWrite, PayloadSize), ));clientProgressBar-setMaximum(TotalBytes);clientProgressBar-setValue(bytesWritten);clientStatusLabel-setText(tr(Sent %1MB).arg(bytesWritten / (1024 * 1024))); } 服务端 绑定信号槽用于新连接connect(tcpServer, QTcpServer::newConnection,this, Dialog::acceptConnection);监听客户端连接。!tcpServer.isListening() !tcpServer.listen()服务端新连接到来void Dialog::acceptConnection() {tcpServerConnection tcpServer.nextPendingConnection();if (!tcpServerConnection) {serverStatusLabel-setText(tr(Error: got invalid pending connection!));return;}connect(tcpServerConnection, QIODevice::readyRead,this, Dialog::updateServerProgress); /* 接受客户端数据的槽函数 */connect(tcpServerConnection,QOverloadQAbstractSocket::SocketError::of(QAbstractSocket::error),this, Dialog::displayError); /* 错误反馈 */connect(tcpServerConnection, QTcpSocket::disconnected,tcpServerConnection, QTcpSocket::deleteLater); /* 断开反馈 */serverStatusLabel-setText(tr(Accepted connection));tcpServer.close(); }接收来自客户端的数据void Dialog::updateServerProgress() {bytesReceived int(tcpServerConnection-bytesAvailable());tcpServerConnection-readAll(); /* 读数据 */serverProgressBar-setMaximum(TotalBytes);serverProgressBar-setValue(bytesReceived); /* 设置进度条 */serverStatusLabel-setText(tr(Received %1MB) /* 显示在界面上 */.arg(bytesReceived / (1024 * 1024)));if (bytesReceived TotalBytes) {tcpServerConnection-close();startButton-setEnabled(true); #ifndef QT_NO_CURSORQApplication::restoreOverrideCursor(); #endif} } 关于更多 在QtCreator软件可以找到或在以下Qt安装目录找到C:Qt{你的Qt版本}Examples{你的Qt版本}networkloopback相关链接https://doc.qt.io/qt-5/qtnetwork-loopback-example.htmlQt君公众号回复『Qt示例』获取更多内容。
http://www.zqtcl.cn/news/803859/

相关文章:

  • 几分钟弄清楚php做网站中国风景摄影网
  • 卡片式网站网页设计公司的市场评估
  • 网站开发的感想wordpress水煮鱼
  • 网站开发入门培训机构自豪地采用wordpress更改
  • 手机网站来几个最近的国际新闻大事件
  • 重庆网站开发设计公司电话资源网站优化排名
  • 国土分局网站建设方案外贸seo网站
  • 营销型网站建设易网拓烟台h5网站建设公司
  • PHP网站开发都需要学什么中介网站模板
  • 网站建设与维护模板官方网站建设费用应入什么科目
  • 网站建设企业关键词seo关键词库
  • 美容院网站源码wordpress scandir
  • 长春电商网站建设报价北京创意设计协会网站
  • 企业3合1网站建设公司加强政协网站建设
  • 专业做互联网招聘的网站有哪些内容百度搜索引擎推广收费标准
  • 物流网站开发系统论文怎么知道网站程序是什么做的
  • 湖南高端网站制作公php网站后台
  • 建好的网站在哪里wordpress部署到git
  • 浙江坤宇建设有限公司网站毕业设计 旅游网站建设
  • 做网站月收入多少视频短视频api
  • 泰安网站建设哪家强网站流量指标
  • 网站毕业设计开题报告wordpress账户密码忘记
  • 做网站学费多少钱0基础学app程序开发
  • 忻州建站公司辽宁省建设执业信息网官网
  • 北京网站建设 云智互联集安网站建设
  • 无锡市建设培训中心网站私人订制软件平台
  • 宁波网站设计推荐荣盛网络招远网站制作
  • 网站开发维护运维室内设计师怎么找
  • 网站建设如何增加二级页面学网络工程好找工作吗
  • 网站设计的研究方法有哪些wordpress样式路径