i am using boost thread for collecting images from camera and i call Qt signal whenever new image arrives. Now when this signal is emitted the connected slot run in which i am updating the widget the control comes to my slot but it dont update the widget while it prints on console for debugging. My question is whether this slot runs in main thread or in the thread which is emitting the signal and how to achieve the desired update? Thanks
Asked
Active
Viewed 1,667 times
3
-
1I never used boost, but Qt has a really clean and simple interface for threads: [QThread](http://doc.qt.nokia.com/4.7-snapshot/qthread.html) – Balázs Édes Aug 26 '12 at 13:48
1 Answers
1
The slot will run in whatever thread created the Qt widget. Qt will use a QueuedConnection on cross thread signals and slots.
Edit: This may be useful signal qt from a non-qt thread, QueuedConnection
Are you blocking the main thread?

Community
- 1
- 1

drescherjm
- 10,365
- 5
- 44
- 64
-
No the main thread is running in routine. The main problem is that since main(GUI) thread is responsible for painting and updating stuff and my SLOT is defined in Main thread still why i cant update it. i can achieve other tasks except related to GUI from that SLOT which means that the SLOt is being run by the signal emitting Thread. (correct me if i am wrong) what can u suggest for this issue? – zulqarnain haider Aug 28 '12 at 11:54
-
Did you try forcing the connect to use a Qt::QueuedConnection instead of letting it decide. Some of the discussion I have seen on this said that this is required. I have not tried emitting signals from boost threads myself yet so I am not sure if that is required. I know this is not needed from a QThread since I have done this in previous applications. – drescherjm Aug 28 '12 at 12:39
-
yes i also tried that but doesnt change anything may be i shift my application from boost to QThread. – zulqarnain haider Aug 29 '12 at 08:04
-
Did you create the Qt object that emits the signal from the boost thread in the Application thread or was that created in the boost thread. I believe you need to create the Qt object in the boost thread since you can not use QObject::moveToThread with a boost thread. – drescherjm Aug 29 '12 at 12:15