Results 1 to 4 of 4

Thread: How to connect a 'silent' signal to a slot with parameter?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to connect a 'silent' signal to a slot with parameter?

    I have 4 buttons (play first, play last, play next, play last).
    I'd like to connect them with the same slot, passing a parameter.
    I can't ( or I dont know how to ) - I need something like this :
    Qt Code:
    1. connect (widget, SIGNAL(clicked),this,play_action(0));
    2. connect (widget, SIGNAL(clicked),this,play_action(1));
    3. connect (widget, SIGNAL(clicked),this,play_action(2));
    4. connect (widget, SIGNAL(clicked),this,play_action(3));
    To copy to clipboard, switch view to plain text mode 

    Any idea ?
    Thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to connect a 'silent' signal to a slot with parameter?

    Read about QSignalMapper

  3. #3
    Join Date
    Jun 2011
    Location
    Chennai, India
    Posts
    30
    Thanks
    13
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to connect a 'silent' signal to a slot with parameter?

    Look at QSignalMapper

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to connect a 'silent' signal to a slot with parameter?

    Last edited by stampede; 26th August 2011 at 07:20. Reason: LOL, nice one

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. Slot - Signal with parameter
    By Lodhart in forum Newbie
    Replies: 8
    Last Post: 10th April 2013, 10:08
  3. Replies: 3
    Last Post: 3rd May 2009, 14:15
  4. Problem with connect() (enum-type as parameter)
    By alu23 in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:46
  5. How to add a parameter to a slot
    By Potch in forum Newbie
    Replies: 4
    Last Post: 5th May 2008, 23:09

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.