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

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Mar 21 08:35:55 CET 2011


Please don't top-post! :)

On Mon, Mar 21, 2011 at 12:34 PM, sarvesh saran
<aquarian.thunder at gmail.com> wrote:
> Hi,
> Can you kindly explain what you mean by "using my class's signals directly?"

I meant making a direct connection (Qt::DirectConnection) to the
signal. I do not want the caller to do connect its slot as a direct
connection.

> how does your approach force users of your class to only use queued
> connections?

Leaving the 'access control' problem mentioned by Andre, if users
connect to 'mySignal()' (and not use 'myInternalSignal()'), then their
slots _should_ be called in a queued manner (since the signal chaining
is done internally with a queued connection).

I mention 'should' as I've yet to verify this approach. Will post back
my findings soon.

Hope this explains it.

-mandeep

> thanks,
> Sarvesh
>
> On Mon, Mar 21, 2011 at 12:00 PM, Mandeep Sandhu
> <mandeepsandhu.chd at gmail.com> 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);
>>
>> Basically I'm chaining my signal and re-emitting it with the queued
>> connection type (I've yet to verify this code though).
>>
>> How can one verify if the slot is indeed called in a queued connection?
>>
>> Thanks,
>> -mandeep
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>



More information about the Qt-interest-old mailing list