Can't catch newConnection() signal from QTcpServer
Posted
by Bob
on Stack Overflow
See other posts from Stack Overflow
or by Bob
Published on 2010-05-12T15:24:50Z
Indexed on
2010/05/12
15:44 UTC
Read the original article
Hit count: 228
qt
|visual-studio
I am trying to make a simple server thread in QT to accept a connection, however although the server is listening (I can connect with my test app) I can't get the newConnection() signal to be acted on.
Any help as to what I'm missing here would be much appreciated!
class CServerThread : public QThread
{
Q_OBJECT
protected:
void run();
private:
QTcpServer* server;
public slots:
void AcceptConnection();
};
void CServerThread::run()
{
server = new QTcpServer;
QObject::connect(server, SIGNAL(newConnection()), this, SLOT(AcceptConnection()));
server->listen(QHostAddress::Any, 1000); // Any port in a storm
exec(); // Start event loop
}
void CServerThread::AcceptConnection()
{
OutputDebugStringA("\n***** INCOMING CONNECTION"); // This is never called!
}
© Stack Overflow or respective owner