QWidget *TcpServerListener::requestGui(QWidget *parent) { NetworkConfWidget *ncw = new(std::nothrow)NetworkConfWidget(NetworkConfWidget::TCP_SERVER,parent); if (ncw == NULL) { qFatal("Cannot allocate memory for NetworkConfWidget X{"); } ncw->setPort(port); ncw->setIP(listeningAddress); ncw->enableDecodeEncodeOption(true); connect(ncw, SIGNAL(newIp(QHostAddress)), this, SLOT(setListeningAddress(QHostAddress))); connect(ncw, SIGNAL(newPort(quint16)), this, SLOT(setPort(quint16))); connect(ncw, SIGNAL(start()), this, SLOT(startListening())); connect(ncw, SIGNAL(stop()), this, SLOT(stopListening())); connect(ncw,SIGNAL(restart()), this, SLOT(restart())); connect(this, SIGNAL(started()), ncw, SLOT(onServerStarted())); connect(this, SIGNAL(stopped()), ncw, SLOT(onServerStopped())); return ncw; }
void MainWindow::initServer() { connect(server, SIGNAL(started(quint16)), SLOT(onServerStarted(quint16))); connect(server, SIGNAL(stopped()), SLOT(onServerStopped())); connect(server, SIGNAL(message(const QString&)), SLOT(message(const QString&))); }