[Qt-interest] Forcing a signal "emit" to be queued
Andre Somers
andre at familiesomers.nl
Mon Mar 21 11:31:48 CET 2011
Op Ma, 21 maart, 2011 10:36 am, schreef Mandeep Sandhu:
>>> connect(this, SIGNAL(myInternalSignal(), this, SIGNAL(mySignal()),
>>> Qt::QueuedConnection);
>>
>> I guess you can also use QMetaObject::invokeMethod() to queue the signal
>> emission
>> or even a QTimer::singleShot() with a 0 timeout.
>
> Ummm...for that I will have to rely on the 'caller' to make the queued
> connection (via invokeMethod()). Whereas, I want this to be decided by
> the class thats emitting the signal.
No, actually that will allow you to do this without using a private signal
at all. You can invoke a signal using invokeMethod() with a queued
connection, or you can use the single shot timer connected to your public
signal. Both methods would rid you of the private signal, and hence of the
private class (if you did not need this for other purposes anyway).
André
More information about the Qt-interest-old
mailing list