Results 1 to 4 of 4

Thread: Can I send a signal with several parameters to a slot with only one parameter?

  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Can I send a signal with several parameters to a slot with only one parameter?

    Hi dudes!

    Can I send a signal with several parameters to a slot with only one parameter?
    Is this possible:
    connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(UpdateSecondInteger(int)));
    How can I choose which parameter I send? (Let's say I'd like to send the 2nd param to this slot)


    Thanks for help.

  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: Can I send a signal with several parameters to a slot with only one parameter?

    Quote Originally Posted by ricardo View Post
    Hi dudes!
    Hi

    Can I send a signal with several parameters to a slot with only one parameter?
    Is this possible:
    connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(UpdateSecondInteger(int)));
    Yes, it's possible.

    How can I choose which parameter I send? (Let's say I'd like to send the 2nd param to this slot)
    You can't. It will be always the first one. The leftover parameters will be ignored. You can implement an intermediate slot that will call UpdateSecondInteger() with desired parameters, though.
    J-P Nurmi

  3. #3
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can I send a signal with several parameters to a slot with only one parameter?

    Quote Originally Posted by jpn View Post
    You can implement an intermediate slot that will call UpdateSecondInteger() with desired parameters, though.
    Thanks for reply. How can I do it?

  4. #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: Can I send a signal with several parameters to a slot with only one parameter?

    I meant something like this:
    Qt Code:
    1. connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(intermediateSlot(int,int,int)));
    2.  
    3. void Foo::intermediateSlot(int a, int b, int c)
    4. {
    5. Q_UNUSED(a);
    6. Q_UNUSED(c);
    7. UpdateSecondInteger(b);
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    ricardo (5th May 2009)

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. Replies: 12
    Last Post: 18th September 2008, 15:04
  4. Replies: 2
    Last Post: 16th August 2007, 00:20
  5. Manually send signal to slot
    By donmorr in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2006, 15:03

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.