35 lines
551 B
C
35 lines
551 B
C
|
#ifndef WIDGET_H
|
||
|
#define WIDGET_H
|
||
|
|
||
|
#include <QWidget>
|
||
|
// 包含 TCP Server 所需的头文件
|
||
|
#include <QTcpServer>
|
||
|
#include <QTcpSocket>
|
||
|
|
||
|
// 需要监听的端口号
|
||
|
#define PORT 8000
|
||
|
|
||
|
QT_BEGIN_NAMESPACE
|
||
|
namespace Ui { class Widget; }
|
||
|
QT_END_NAMESPACE
|
||
|
|
||
|
class Widget : public QWidget
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
Widget(QWidget *parent = nullptr);
|
||
|
~Widget();
|
||
|
|
||
|
private slots:
|
||
|
// 新客户端连接函数
|
||
|
void newClientHandler();
|
||
|
|
||
|
private:
|
||
|
Ui::Widget *ui;
|
||
|
|
||
|
// 初始化 QTcpServer 类
|
||
|
QTcpServer *server;
|
||
|
};
|
||
|
#endif // WIDGET_H
|