Hi.
I'm trying to implement tcpserver which runs alongside the GUI program. Here are the classes:
MainWindow:
MainWindow::MainWindow()
{
serverThread = new ServerThread(this);
serverThread->start();
}
MainWindow::MainWindow()
{
serverThread = new ServerThread(this);
serverThread->start();
}
To copy to clipboard, switch view to plain text mode
ServerThread(QThread):
void ServerThread::run()
{
server = new Server(NULL);
//How to connect MainWindow slots with Server signals?
exec();
}
void ServerThread::run()
{
server = new Server(NULL);
server->listen(QHostAddress::Any, DEF_PORT);
//How to connect MainWindow slots with Server signals?
exec();
}
To copy to clipboard, switch view to plain text mode
Server(QTcpServer):
{
connect(this, SIGNAL(newConnection()), this, SLOT(addConnection()));
}
Server::Server(QObject *parent) : QTcpServer(parent)
{
connect(this, SIGNAL(newConnection()), this, SLOT(addConnection()));
}
To copy to clipboard, switch view to plain text mode
How do I connect MainWindow slots with Server signals and am I doing this the right way?
Bookmarks