首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

QTcpServer监听不到newConnection,该如何解决

2012-08-27 
QTcpServer监听不到newConnection//构造函数, 类继承与QWidget.................this-m_temptcpServer

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和当前代码是在同一个线程中吗?

热点排行