Issue with Qt thread affinity and moveToThread

后端 未结 4 1883
长发绾君心
长发绾君心 2021-01-13 07:58

I\'m trying to use threads in Qt to delegate some work to a thread, but I can\'t get it to work. I have a class inheriting QMainWindow that have a member object that launch

4条回答
  •  长情又很酷
    2021-01-13 08:47

    If you are moving your object through signals and slots (you have created your m_poller in one thread and called a signal and passed it to a slot of another object which is not in caller thread) make sure to use Qt::DirectConnection type for your connect. In this way your slot will execute in the caller thread and calling moveToThread is in the caller thread.

提交回复
热议问题