Results 1 to 6 of 6

Thread: Problem with unused parameter

  1. #1
    Join Date
    Jul 2007
    Location
    Scottsdale, AZ USA
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem with unused parameter

    I have a function:

    Qt Code:
    1. QCheckBox *Window::createCheckBox(const QString &text, const QString &key)
    2.  
    3. {
    4.  
    5. QCheckBox *checkBox = new QCheckBox(text);
    6.  
    7. connect(checkBox, SIGNAL(stateChanged(2)), this, SLOT(addKeyword(key)));
    8.  
    9. connect(checkBox, SIGNAL(stateChanged(0)), this, SLOT(killKeyword(key)));
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    When I compile I receive:

    warning: unused parameter ‘key’

    Any thoughts?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with unused parameter

    Be careful, you're not using signals & slots in the good way !
    You should check the docs to understand it better, and see some examples ;-)

    You cannot connect signals with explicit parameters, you have to use QSignalMapper to achieve this.

    Here, you can do something like that :

    Qt Code:
    1. connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(addKeyword(int)));
    To copy to clipboard, switch view to plain text mode 

    You can only specify parameter types, not parameter values !

    Guilugi.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with unused parameter

    Quote Originally Posted by devilj View Post
    When I compile I receive:

    warning: unused parameter ‘key’
    Omit the parameter name or use Q_UNUSED(key) to mark the variable as unused, preventing the warning from showing up.

    And correct those signal/slot connections as advised.

  4. #4
    Join Date
    Jul 2007
    Location
    Scottsdale, AZ USA
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with unused parameter

    Thanks for the response and your patients with a newbie....

    So am I to gather that a signal doesn't neccessarily trigger a slot.

    For instance just because SIGNAL(stateChanged()) emits a "2" doesn't mean my SLOT(addkeyword()) automatically triggers. In essence I need to "spy" on this signal and is this where SignalSpy and Signal Mapping come in? If so, is the result of the spying a variable that can be evaluated.

    Thanks

  5. #5
    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: Problem with unused parameter

    Recommended reading: Signals and Slots.
    J-P Nurmi

  6. #6
    Join Date
    Jul 2007
    Location
    Scottsdale, AZ USA
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with unused parameter

    Ok, I see!

    So really what I want to do is not rely on pre-defined slots and signals but create my own subclass wigets that will do what I want...more work, but MORE POWER!

Similar Threads

  1. Qtopia core 4.2.2 cross compile make error
    By smiyai18 in forum Installation and Deployment
    Replies: 2
    Last Post: 28th August 2007, 17:04
  2. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

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.