Results 1 to 5 of 5

Thread: Common slot on some widgets [Qt3]

  1. #1
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Common slot on some widgets [Qt3]

    Hello!

    I have some QToolButton widgets on my QDialog. I want to use common slot to process clicked() signal. How can I know wich one of the QToolButton was clicked?

  2. #2
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: Common slot on some widgets [Qt3]

    u have connectio (blabla, SIGNAL(clicked()),SLOT(slot()))

    void ClassName::slot()
    {
    QToolButton* tb = qobject_cast<QToolButton*>(sender());
    if (tb)
    {
    do something with current toolbutton
    }
    }

  3. The following user says thank you to evgenM for this useful post:

    Opilki_Inside (27th March 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Common slot on some widgets [Qt3]

    Quote Originally Posted by evgenM
    u have connectio (blabla, SIGNAL(clicked()),SLOT(slot()))

    void ClassName::slot()
    {
    QToolButton* tb = qobject_cast<QToolButton*>(sender());
    if (tb)
    {
    do something with current toolbutton
    }
    }
    Thanks! It works fine!

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Common slot on some widgets [Qt3]

    You could also use a QButtonGroup..

  6. #5
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Common slot on some widgets [Qt3]

    In this case it's more "elegant" to use QButtonGroup assigning an identificator for each icon.

Similar Threads

  1. How to create Custom Slot upon widgets
    By ashukla in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2007, 14:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.