[Qt5-feedback] Make some undocumented features documented

BRM bm_witness at yahoo.com
Wed May 25 11:45:01 CEST 2011


Q_PRIVATE_SIGNAL
- internal to a class. e.g. you want to be notified by a signal/slot but do not 
want it to propagate to derived classes.
Example: A network interface class - notification that something is on the wire 
to read off

Q_PROTECTED_SIGNAL
- internal to the class and derived classes, but not accessible to outside 
classes.
Example: A network interface class - notification to decode a given message read 
off the wire

Comparatively Q_SIGNAL should be for when the class wants to notify an external 
object, while Q_PROTECTED_SIGNAL is about notifying itself and all derived 
classes and Q_PRIVATE_SIGNAL is about notifying just itself.
For example, I have one class that reads data off the wire (myNetworkInterface), 
and several derived classes that are specific to different data streams 
(myNetworkData1, myNetworkData2). I use signals/slots to read the data off the 
network (myNetworkInterface is derived from QTcpSocket) and others to 
communicate the derived classes. However, I don't really want the users of the 
data streams (e.g. myNetworkData1) to be accessing those signals - I really only 
want to expose one signal to them to give them the data - one that is specific 
to the data stream. This lets me use common code to do common stuff on the 
network layer - e.g. low level protocol that everyone shares - while 
differentiating the data streams higher up.

Q_PROTECTED_SLOT
- probably just an easier way to write "protected Q_SLOTS" now that I think 
about it more. It's probably more readability/clarity than anything else.

FYI - I typically only use the Q_SLOTS/Q_SIGNALS macros myself, namely as I 
don't want the underlying interface to change if say Boost Signal/Slot mechanism 
was used instead of Qt Signal/Slot - e.g. I always want to use the Qt mechanism.

Ben

From: Konstantin Ritt <ritt.ks at gmail.com>
>
>To: qt5-feedback <qt5-feedback at qt.nokia.com>
>Sent: Wed, May 25, 2011 1:08:21 AM
>Subject: Re: [Qt5-feedback] Make some undocumented features documented
>
>
>Ben,
>
>same question about Q_PROTECTED_SLOT... 
>could you provide us with some use-cases?
>Konstantin
>
>
>
>
>2011/5/24 Thiago Macieira <thiago at kde.org>
>
>On Tuesday, 24 de May de 2011 14:20:50 BRM wrote:
>>> Well, since we're mentioning those things, if it doesn't exist already, how
>>> about a Q_PROTECTED_SLOT too. I have a number of classes that could really
>>> use protected slots. Same for signals - Q_PRIVATE_SIGNAL and
>>> Q_PROTECTED_SIGNAL would be very beneficial.
>>
>>Signals are always protected in Qt 4. In Qt 5, this may change.
>>
>>What's a Q_PROTECTED_SLOT for you? And how is this different from "protected
>>slots:" ?
>>
>>--
>>Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>> Senior Product Manager - Nokia, Qt Development Frameworks
>>     PGP/GPG: 0x6EF45358; fingerprint:
>>     E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>>
>>_______________________________________________
>>Qt5-feedback mailing list
>>Qt5-feedback at qt.nokia.com
>>http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110525/3accb7e1/attachment.html 


More information about the Qt5-feedback mailing list