[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Question about multiple KActions in a menu
From:       Ian Wadham <ianw2 () optusnet ! com ! au>
Date:       2008-04-04 22:19:31
Message-ID: 200804050920.05460.ianw2 () optusnet ! com ! au
[Download RAW message or body]

On Sat, 5 Apr 2008 01:06 am, Carsten Niehaus wrote:
> QSignalMapper might be the correct approach, but I am not getting
> it to work. Perhaps somebody here can have a look if this approach
> is basically correct or if I am using the wrong approach...
>
>     QSignalMapper *speedStepMapper = new QSignalMapper( this );
>     connect( speedStepMapper, SIGNAL( mapped( int ) ),
>                   this, SLOT( setSimulationSpeed( int ) ) );
>
>     for ( uint i = 0; i < 4; ++i ) {
>         KAction *speedAction = new KAction(
>                   i18n( "Set Speed to %i x", i), this );
>         connect( speedAction, SIGNAL( triggered(bool) ),
>                   speedStepMapper, SLOT( map()) );
>         speedStepMapper->setMapping( speedAction, i );
>     }
>
Not an expert, but I have several working uses of QSignalMapper
in Kubrick (a 3-D cube game), which is currently in .../kdereview.

You seem to be following the QSignalMapper example in the API
for KAction, but I think it must be out of date (it uses i18n(...).arg
for example).  Maybe it would not work in KDE 4 either.

The main difference I can see (from Kubrick cases) is that your
example is not giving the action an internal ID (e.g. "speed_%1")
and adding it to actionCollection().

Also, in some places I am using two "const int"s in the first connect.

Hope this helps, Ian W.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic