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 <[email protected]>
>
>To: qt5-feedback <[email protected]>
>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 <[email protected]>
>
>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
>>[email protected]
>>http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
>>
>>
>
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to