Qt Signals and slot thread safety

前端 未结 1 685
挽巷
挽巷 2021-01-01 10:58

Let\'s say I have a signal change connected to a slot notify. If the change signal is emitted, the notify slot will start executing.

Now what happ

相关标签:
1条回答
  • 2021-01-01 11:16

    It depends on connection type you specified via calling connect function. The only way when slot will be launched concurrently is if you specified Qt::DirectConnection AND emitting signal in thread different from slot's thread. If you omit connection type, it would be Qt::AutoConnection. In this case if you emit a signal from one thread, and catching it in another one (e.g. in main GUI thread) - Qt will put a slot's call to the message queue and will make all calls sequentially. Read this for further info - http://qt-project.org/doc/qt-4.8/threads-qobject.html#signals-and-slots-across-threads

    0 讨论(0)
提交回复
热议问题