QT 发送signal但是无法到达SLOT函数,修改下程序就可以,望大牛解答为什么?
童心童颜 2015-07-30 08:32:35 main函数部分代码如下:
Message_Handler * pMsgHandler = new Message_Handler();
QThread *pMsgHandlerThread = new QThread;
pMsgHandler->moveToThread(pMsgHandlerThread);
QObject::connect(pMsgHandlerThread, SIGNAL(started()), pMsgHandler, SLOT(handleMessage()));
pMsgHandlerThread->start(QThread::NormalPriority);
QObject::connect(pServerStatusGui, SIGNAL(signalSendClientSetupInitNetMsg()),pMsgHandler, SLOT(sendClientSetupInitNetMsg()),Qt::AutoConnection);
如果我发送signalSendClientSetupInitNetMsg(),那么QT无法找到slot sendClientSetupInitNetMsg()
如果程序修改成
Message_Handler * pMsgHandler = new Message_Handler();
//QThread *pMsgHandlerThread = new QThread;
// pMsgHandler->moveToThread(pMsgHandlerThread);
// QObject::connect(pMsgHandlerThread, SIGNAL(started()), pMsgHandler, SLOT(handleMessage()));
// pMsgHandlerThread->start(QThread::NormalPriority);
QObject::connect(pServerStatusGui, SIGNAL(signalSendClientSetupInitNetMsg()),pMsgHandler, SLOT(sendClientSetupInitNetMsg()),Qt::AutoConnection);
如果我发送signalSendClientSetupInitNetMsg(),那么QT能够找到slot sendClientSetupInitNetMsg()
想问下这个是怎么回事啊?