Programatically generated slot names

Sebastian TrĂ¼g trueg at kde.org
Thu Jan 29 17:50:58 GMT 2009


there is always QMetaObject::invokeMethod
which is much thinner than a QTimer.

Cheers,
Sebastian

On Wednesday 28 January 2009 01:30:49 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.  The various things I've tried to far don't work, either because
> the constructed string gets mangled, or because I don't have SLOT around
> it which seems to be a requirement at some level (even if I'm
> duplicating its functionality as defined in the relevant header file,
> which I don't remember right now).
>
> Anyone know if this is possible?
>
> Thanks,
> Jeff





More information about the kde-core-devel mailing list