[Kde-games-devel] Re: Connect a button with KGameIO
Andreas Beckermann
b_mann at gmx.de
Mon Sep 15 04:03:37 CEST 2003
On Sunday 14 September 2003 02:57, cantabile wrote:
> Hi,
> I'm trying to connect a button (in a toolbar) with a KGameIO method, and
> I don't succeed at the moment.
> Since the KGameIO is linked to the player, not to a view or a document
> object, how can I do it ?
> My button is created via :
> KAction * action = new KAction(play,...)
> My KGameIO method is in an inherited class. We can call it moveDone, as
> Andreas and Martin suggested before.
>
> I tried while constructing the interface
>
> connect(play, SIGNAL(clicked()), ***, SLOT(slotPlay()));
>
> But the problem is with the ***: KGAmeIO* io doesn't work, of course,
> since it isn't instanciated.
what about
connect(play, SIGNAL(clicked()), mLocalPlayerIO, SLOT(slotPlay()));
assuming mLocalPlayerIO is your KGameIO derived class that has a slot called
"slotPlay()".
Another solution (I usually prefer that one):
connect(play, SIGNAL(clicked()), this, SLOT(slotPlay()));
and
MyWidget::slotPlay()
{
mLocalPlayerIO->doSomthing();
}
> I tried also to connect the method in the KGamIO constructor, but the
> button (play) isn't recognize (build) yet.
> I also tried to get the io from the player (in slotPlay() )but didn't
> find a method with a KGameIO return type.
What about KPlayer::findRttiIO(rttiOfYourKGameIO) ?
(don't forget to check for NULL in case of errors)
The mLocalPlayerIO above can be replaced by a call to findRttiIO() of course
(and maybe a cast to the derived class)
> This is certainly a stupid question but I'm stuck there :)
> Thanks for your help.
CU
Andi
More information about the kde-games-devel
mailing list