Communication between QRunnable and main thread
Hi all,
To tell the user that the QRunnable threads have not stalled, I would like them to provide some feedback to the main GUI. But QRunnable does not inherit QObject, hence doesn't seem to provide the capability of signal emission.
So, how can a QRunnable thread communicate to the main thread ?
Thanks
Andre
Re: Communication between QRunnable and main thread
I see two options for signaling from a QRunnbale:
1. Since QRunnable is not a QObject, you can multiple inherit from QObject:
Code:
class MyRunnable
: public QRunnable,
public QObject{
...
};
Note - at least in theory - I didn't try it.
The other option is to have a member in your QRunnable which is a QObject, and signal from that object.
Re: Communication between QRunnable and main thread
Re: Communication between QRunnable and main thread
Just for information, I found a way using postEvent() from the QRunnable thread to the main thread.
Re: Communication between QRunnable and main thread
Yes, that is true, you can always send an event, and before Qt4.X that was the only way to "signal" between threads (signals where not possible)
But you asked about sending signals, so...