我試圖使QT一個簡單的服務器線程接受連接趕上newConnection()信號,然而儘管服務器監聽(我可以用我的測試應用程序連接),我不能讓newConnection()信號起作用。無法從QTcpServer既可
任何幫助,因爲我在這裏失蹤將不勝感激!
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!
}
非常感謝,我將這個返工的建議。 – Bob 2010-05-12 15:52:56