[Qt-interest] Forcing a signal "emit" to be queued

Mohammed Sameer msameer at foolab.org
Mon Mar 21 09:04:32 CET 2011


On Mon, Mar 21, 2011 at 12:00:03PM +0530, Mandeep Sandhu wrote:
> Hi All,
> 
> Sometime back I had a requirement where I didn't want ppl using my
> class's signals to connect to them directly. Currently if you do 'emit
> mySignal()', it's upto to the class that uses this signal, to decide
> how it would like to connect to it.
> 
> For forcing a queued a connection, I thought of the following approach:
> 
> 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.

The only advantage I can see is not having an extra signal that the users will eventually
discover and use ;-)

Cheers,

-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org



More information about the Qt-interest-old mailing list