[Qt-interest] Forcing a signal "emit" to be queued
Andre Somers
andre at familiesomers.nl
Mon Mar 21 13:07:10 CET 2011
Op Ma, 21 maart, 2011 12:54 pm, schreef Mandeep Sandhu:
>> 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).
>
> Oh yes, I forgot that I could give a signal name to invokeMethod()
> too. Though the only 'technical' limitation here is the number of args
> that one can pass to invokeMethod (max is 10). Though it might not be
> much of an issue in most cases.
>
> As for the singleShot approach, will it have an overhead of creating a
> OS specific timer underneath (even for a timeout of 0)? Not sure how
> heavy creation/destruction of such timer is.
>
> Thanks again for all your ideas.
If you are worried about that, then perhaps look into QObject::startTimer
and QObject::timerEvent(). It is the low-level way of using a timer, and
it is already available in your object. A timer with a timeout of 0 will,
AFAIK, just post a message to the eventqueue anyway.
André
More information about the Qt-interest-old
mailing list