?? dialogimpl.cpp
字號:
#include "dialogimpl.h"//DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f) : QDialog(parent, f){ setupUi(this); connect(ReceiveButton,SIGNAL(clicked()),this,SLOT(ReceiveFromClient())); connect(StartServerButton,SIGNAL(clicked()),this,SLOT(startServer())); connect(&tcpServer,SIGNAL(newConnection()),this,SLOT(acceptConnection())); connect(QuitButton, SIGNAL(clicked()), this, SLOT(close()));}void DialogImpl:: startServer(){ while(!tcpServer.isListening()&&!tcpServer.listen(QHostAddress::LocalHost,16689)) { QMessageBox messageBox(QMessageBox::Question,"Fail","Listening fail"); messageBox.exec(); } StartServerButton->setEnabled(false); }void DialogImpl:: ReceiveFromClient(){ char data[1024]; tcpServerConnection->read(data,1024); QString str(data); ReceiveText->setText(str); StartServerButton->setEnabled(true); }void DialogImpl::acceptConnection(){ //表示接受到了一個新的連接 tcpServerConnection=tcpServer.nextPendingConnection(); QMessageBox messageBox(QMessageBox::Question,"New Connection","New Connection"); messageBox.exec(); }//
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -