服务器
-
新建工程,Base class 选择 QWidget,在工程文件 tcpServer.pro 中添加一行代码:QT += network。
QT += core gui QT += network
-
ui 中添加一个 label,用于显示状态信息。
-
在 widget.h 文件中做以下更改
- 添加头文件
#include<QtNetwork/QtNetwork>
- 添加 private 对象
QTcpServer *tcpServer;
- 添加私有槽函数
private slots: void SendMessage();
4.在 widget.cpp 文件中进行更改。
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
tcpServer =