Programatically generated slot names

Olivier Goffart ogoffart at kde.org
Fri Jan 30 08:01:37 GMT 2009


Le jeudi 29 janvier 2009, Jeff Mitchell a écrit :
> David Faure wrote:
> > On Thursday 29 January 2009, Richard Moore wrote:
> >> The SLOT macro actually tags a value to the end of the token iirc.
> >
> > No, at the beginning ;)
> >
> > qobjectdefs.h:#define SLOT(a)           "1"#a
> > qobjectdefs.h:#define SIGNAL(a)        "2"#a
> >
> > This allows connect() to distinguish signal-to-slot connections
> > from signal-to-signal connections.
> >
> > (and to barf on slot-to-signal connections like the one I found in plasma
> > today :-)
>
> Yeah, early on I tried removing SLOT from the name and simply prepending
> "1" to the function name.  

That should have worked. (assuming the signature name was correct, with 
parenthesis and arguments)

> Didn't work because something was looking for 
> the actual chars "SLOT(" in the method name, according to the odd
> runtime output.

Nothing check for the "SLOT(", or maybe just your IDE that want to do 
autocompletion.
But the moc doesn't parce .cpp files   (if they don't contain class 
declaration with Q_OBJECT)

> I'll check out invokeMethod.  One thing I'm not sure of: if I want to
> let the event loop process events (i.e. I don't need to have the method
> run immediately), will using QueuedConnection have the same effect as a
> singleShot in this case?

Yes, QueuedConnection will have the exact same effect as singleShot of 0ms.  
(But it will be cheaper because you don't need to create a Timer)

> For fun I'll also try the concatenation outside the SLOT macro like
> Kevin suggested, and see if that works too  :-)
>
> Thanks to all,
> Jeff


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090130/688a4fa5/attachment.sig>


More information about the kde-core-devel mailing list