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

QTcpServer监听不到newConnection,该如何处理

2012-08-26 
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()))

[解决办法]
头文件里声明:
private slots:
void getNewConnection();
cpp文件里:
void 类名::getNewConnection()
{
}
你可能没有头文件里加上slots这个关键字

热点排行