[Interest] Does removing 'private slots' from .h files have any advantages? Disadvantages?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sun Mar 8 16:34:46 CET 2015


Il 08/03/2015 12:28, Constantin Makshin ha scritto:
> Both advantages and disadvantages will come from the fact that MOC won't
> generate anything for methods in these sections.

There's an extra pro that comes with that: visibility markers actually 
come into play.

A slot is always publicly invokable via QMetaObject::invokeMethod or a 
suitable connection statement; "public/protected/private" only influence 
its invocation as a normal (member) function.

Instead now you can have "truly private slots" by connecting to private, 
non-slot member functions. Noone but your class and its friends can use 
those functions.

(Note that Qt has also another mechanism for that -- Q_PRIVATE_SLOT -- 
but that doesn't solve the problem, it simply allows to move a slot 
declaration/definition into the pimpl).

HTH,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4048 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150308/f670d351/attachment.bin>


More information about the Interest mailing list