Programatically generated slot names

Kevin Krammer kevin.krammer at gmx.at
Thu Jan 29 17:52:37 GMT 2009


On Wednesday 28 January 2009, Jeff Mitchell wrote:
> For a design I'm putting together, I will need to trigger a series of
> slots in succession, returning to a master "control" function in
> between.  I *could* do something like (very pseudocode):
>
> switch i:
> case 1: singleshot slotPage1
> case 2: singleshot slotPage2
> ...
> case n: singleshot slotPagen
>
> However, what I'd prefer to do is something like this:
>
> singleshot( SLOT( "slotPage" + n.toString() ) )
>
> In other words, since signal and slot names are simply const char *, I'd
> like to be able to construct this value programatically.  However, I
> don't know if this value is needed at moc time, compile time, or run
> time.

Runtime.

Try to do the concatenation outside the SLOT macro, i.e.

SLOT( "slotPage" ) + suffix

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- 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/20090129/ec92b68d/attachment.sig>


More information about the kde-core-devel mailing list