读书人

QTcpServer监听不到newConnection,该如

发布时间: 2012-08-27 21:21:56 作者: rapoo

QTcpServer监听不到newConnection
//构造函数, 类继承与QWidget
.................
this->m_temptcpServer = new QTcpServer(this);
if (!m_temptcpServer->listen(QHostAddress::Any,5697))
{
QMessageBox::warning(this, "提示", "监听端口失败。", QMessageBox::Yes);
}
//在我用另外一个程序连接这个端口的时候,那个程序连接上了,但是我的slot函数从类不会被触发,不知道什么原因,愁死了
connect(this->m_temptcpServer, SIGNAL(newConnection()), this, SLOT(getNewConnection()))

[解决办法]
connect(this->m_temptcpServer, SIGNAL(newConnection()), this, SLOT(getNewConnection()))
LZ的SLOT是当前对象的吗,m_temptcpServer和当前代码是在同一个线程中吗?

读书人网 >C++

热点推荐