Hey Jose,

2008/9/12 Jose M. Sanchez <[EMAIL PROTECTED]>:
>
> Hi,
>
> I have different widgets created in a generic way with slots connected
> to the same method. How can I know which widget triggered the event?
>
> void Test::createWidgets()
> {
>    WText *text1 = new WText(...);
>    WText *text2 = new WText(...);
>    WText *text3 = new WText(...);
>
>    text1->clicked.connect(SLOT(this, Test::onClick));
>    text2->clicked.connect(SLOT(this, Test::onClick));
>    text3->clicked.connect(SLOT(this, Test::onClick));
> }
>
>
>
> void Test::onClick()
> {
>    // how do I know here which WText was clicked?
>
>    WObject *sender = clicked.sender();

You can use sender() (WObject::sender()), or, perhaps better you could
consider using the WSignalMapper.

For an example of using WSignalMapper, see examples/hangman/HangmanWidget.C

Regards,
koen

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to