PDA

View Full Version : Why is not possible call slot with parameters?



somename
28th May 2010, 10:22
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 ?

Zlatomir
28th May 2010, 11:33
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.

SixDegrees
28th May 2010, 11:54
More importantly, you can't pass arguments in the connect statement - only argument types. Trying to pass those integers is an error.

skalmanman
28th May 2010, 14:17
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.