Results 1 to 6 of 6

Thread: many signals, one slot

  1. #1
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default many signals, one slot

    Is it possible to connect may signals to one slot automatically with only 1 signal/slot construct?

    I have 6 radiobuttons and I'd like all of them to trigger the same slot. Do I have to have 6 separate signal/slot declarations or is it possible to somehow achieve it all with just one signal/slot? Perhaps there is a way to group all of these radiobuttons together somehow and treat this group as one signal?

  2. #2
    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: many signals, one slot

    J-P Nurmi

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

    eric (23rd January 2008)

  4. #3
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: many signals, one slot


  5. The following user says thank you to elcuco for this useful post:

    eric (23rd January 2008)

  6. #4
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: many signals, one slot

    Thanks!
    Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.

  7. #5
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: many signals, one slot

    Quote Originally Posted by eric View Post
    Thanks!
    Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.
    See the link mentioned below;
    http://doc.trolltech.com/4.3/qsignalmapper.html#details
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. The following user says thank you to ashukla for this useful post:

    eric (25th January 2008)

  9. #6
    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: many signals, one slot

    Quote Originally Posted by eric View Post
    Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.
    What kind of example would you expect? It returns a pointer to the QObject who sent the signal. You can compare it to a member variable or something:
    Qt Code:
    1. void MyClass::mySlot()
    2. {
    3. if (myButton == sender())
    4. {
    5. // mybutton sent the signal
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  10. The following 2 users say thank you to jpn for this useful post:

    eric (25th January 2008), JeanC (12th February 2008)

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. Signals and slot
    By rajeshclt3 in forum Newbie
    Replies: 1
    Last Post: 29th November 2007, 12:41
  3. Signals and Slots Across Threads
    By themusicalguy in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 11:16
  4. Combobox Signals
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2006, 10:21
  5. Connecting signals & slots across different threads
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 12:40

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.