signal qt from a non-qt thread, QueuedConnection

喜夏-厌秋 提交于 2019-12-20 03:17:19

问题


I am signaling my Qt GUI thread from a boost::thread, and I am using a Qt::QueuedConnection,

 connect(src, SIGNAL(signal-signature), dest, SLOT(slot-signature), Qt::QueuedConnection);

and still, when I emit the signal my slot does not get called.

edit: I found the problem, it seems that I was connecting the signal later then my call, but I was sure of the otherwise since breakpoints stopped first on the GUI thread at the connect call and then on the dispatch thread that does the emit

ty everybody for the help and ideas :D


回答1:


Check whether the slot name and signal name are correct. Usually, if there is a problem (incorrect name), this is signaled in the console (an error message). Also, you could check the result of the connect function call. It should return false in case of connection unsuccessful.




回答2:


I would assume both threads need to be QThread with a QEventLoop to have that work.



来源:https://stackoverflow.com/questions/2689450/signal-qt-from-a-non-qt-thread-queuedconnection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!