Main thread call from another thread
-
I am trying to post an event, and call the main thread, since in opencv gui function don't work otherwise. I tried also to move the object to the main thread by using
moveToThread(QGuiApplication::instance()->thread());
but the output i get isn't showing any results
currentThread: QThread(0x22fd70) -- QGuiApplication::instance: QThread(0x2fcc70)
Events, signals and also this move to thread doesn't fix the issue.. I have to make a signal to the main thread, to execute a function, how to do it then?
-
I am trying to post an event, and call the main thread, since in opencv gui function don't work otherwise. I tried also to move the object to the main thread by using
moveToThread(QGuiApplication::instance()->thread());
but the output i get isn't showing any results
currentThread: QThread(0x22fd70) -- QGuiApplication::instance: QThread(0x2fcc70)
Events, signals and also this move to thread doesn't fix the issue.. I have to make a signal to the main thread, to execute a function, how to do it then?
@Loc888 said in Main thread call from another thread:
I have to make a signal to the main thread, to execute a function, how to do it then?
Well, you create a slot in a class living in main thread, you create a signal in a class living in the other thread, you connect these signal/slot, you emit the signal in the other thread whenever you need to notify the main thread...
If this is not clear then please provide more information.
-
First of all, thise threads don't want to be terminated, even when i call terminate and then wait... What is the cause of that? Exit or quit don't work as well.
@Loc888 said in Main thread call from another thread:
What is the cause of that?
I have no idea - you did not post any code.
You should implement thread termination properly, see https://doc.qt.io/qt-5/qthread.html#requestInterruption and https://doc.qt.io/qt-5/qthread.html#isInterruptionRequested -
Hi,
What are you using from OpenCV's highgui module ?