signal qt from a non-qt thread, QueuedConnection

2019-02-25 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

2条回答
叼着烟拽天下
2楼-- · 2019-02-25 17:45

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.

查看更多
爷的心禁止访问
3楼-- · 2019-02-25 17:50

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

查看更多
登录 后发表回答