Results 1 to 4 of 4

Thread: Why is not possible call slot with parameters?

  1. #1
    Join Date
    May 2010
    Posts
    39
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Why is not possible call slot with parameters?

    i want to do this:

    connect(leftButton, SIGNAL(clicked()), this, SLOT(check(25));
    connect(rightButton, SIGNAL(clicked()), this, SLOT(check(50));

    why slot don't call with 25 or 50 ?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Why is not possible call slot with parameters?

    You can't do that because signal and slot must have the same signature (number and type of parameters).

    A little "exception" is that a slot may have a shorter signature than the signal it receives because it can ignore extra arguments.

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Why is not possible call slot with parameters?

    More importantly, you can't pass arguments in the connect statement - only argument types. Trying to pass those integers is an error.

  4. The following user says thank you to SixDegrees for this useful post:

    Zlatomir (28th May 2010)

  5. #4
    Join Date
    May 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Why is not possible call slot with parameters?

    Look up QSignalMapper!
    It can pick up a parameterless signal from a specified object and re-emit it with an int, const QString &, QWidget* or QObject* parameter.

Similar Threads

  1. QScript + get function call parameters
    By Fastman in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2009, 15:30
  2. Replies: 4
    Last Post: 3rd May 2009, 18:32
  3. Replies: 3
    Last Post: 3rd May 2009, 14:15
  4. who call my slot?
    By mattia in forum Newbie
    Replies: 1
    Last Post: 28th November 2007, 12:44
  5. Replies: 2
    Last Post: 16th August 2007, 00:20

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.