Problem with unused parameter
I have a function:
Code:
{
connect(checkBox, SIGNAL(stateChanged(2)), this, SLOT(addKeyword(key)));
connect(checkBox, SIGNAL(stateChanged(0)), this, SLOT(killKeyword(key)));
}
When I compile I receive:
warning: unused parameter ‘key’
Any thoughts?
Thanks
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 :
Code:
connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(addKeyword(int)));
You can only specify parameter types, not parameter values !
Guilugi.
Re: Problem with unused parameter
Quote:
Originally Posted by
devilj
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.
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
Re: Problem with unused parameter
Recommended reading: Signals and Slots.
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!