📄 form1.ui.h
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include "qserversocket.h"#include "qsocketdevice.h"#include "qsocket.h"#include "qsocketnotifier.h"#include <qcstring.h>#include <qmessagebox.h>#include <qstring.h>#include <qlineedit.h>#include "qhostaddress.h"#define SERVER_IP "192.168.0.2"#define PORT 13000void Form1::link(){ QHostAddress MyAddress; QString FakeAddress; QString str = lineEdit1->text(); QSocketDevice *ServerSocket; QSocketDevice *ClientSocket; QSocketNotifier *ServerNotifier; QSocketNotifier *ClientNotifier; lineEdit2->setText(str); FakeAddress=SERVER_IP; MyAddress.setAddress(FakeAddress); ServerSocket=new QSocketDevice(QSocketDevice::Stream); ClientSocket=new QSocketDevice(QSocketDevice::Stream); ServerSocket->bind(MyAddress,PORT); ServerSocket->listen(20); ClientNotifier=new QSocketNotifier(ClientSocket->socket(),QSocketNotifier::Read,0,"ClientSocket"); ServerNotifier=new QSocketNotifier(ServerSocket->socket(),QSocketNotifier::Read,0,"ServerSocket"); }void Form1::send(){ char information[20]; QString str = lineEdit1->text(); QSocketDevice *ServerSocket; QHostAddress MyAddress; QString FakeAddress; FakeAddress=SERVER_IP; MyAddress.setAddress(FakeAddress); strcpy(information,str); ServerSocket->writeBlock(information,sizeof(information),MyAddress,PORT);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -