[Qt-interest] Question SLOT Macro & messing with the QObject::connect method

Ian Thomson Ian.Thomson at iongeo.com
Fri Feb 5 10:41:31 CET 2010


Hi, you have mistunderstood me.

The functions which you are connecting as slots must fall in to one of 
two cases:

1) Stored as string literals somewhere in your program. In this case, 
call SLOT() on them at the point they are declared and use the const 
char* result. E.g.

const char* slots[] = { SLOT(firstFunc()), SLOT(secondFunc()), 0 };

connect(myButton, SIGNAL(clicked()), myObject, slots[0]);

or

2) Not stored as string literals anywhere, so the connections are 
determined at run time only. In this case you want to use QMetaObject to 
find out what slots are available. This sounds like a different problem 
to the one you are having.

Cheers,
Ian.


kent williams wrote:
> I just have the habit of turning any block of code I need to use over
> and over again into a convenience function.  I'd think EVERYONE would
> want to have that habit, but when I read other people's code it sure
> seems like they're a lot more excited by Cut & Paste in their editor
> than they are about functional decomposition as a programming
> technique.
> 



More information about the Qt-interest-old mailing list