Is there any way to pass default parameters values to any slot?
Hi all!
Is there any way to pass default parameters values to any slot?
I read over there something baout adding an "=", but doesn't work
connect(ui.actionZoom_1X, SIGNAL(triggered()), d, SLOT(UpdateCameraZoom(=1.0)));
Any idea?
Thanks in advance.
Re: Is there any way to pass default parameters values to any slot?
Code:
class Foo
{
public slots:
void UpdateCameraZoom(qreal level = 1.0);
};
void Foo::UpdateCameraZoom(qreal level)
{
// ...
}
connect(ui.actionZoom_1X, SIGNAL(triggered()), d, SLOT(UpdateCameraZoom()));
Re: Is there any way to pass default parameters values to any slot?
Oh my god! I didn't realise I could do that. Works perfectly for me. Thanks
But let's say different default parameters with differente signals calling the same slot. How would you do it?
Thanks.
Re: Is there any way to pass default parameters values to any slot?
Quote:
Originally Posted by
ricardo
But let's say different default parameters with differente signals calling the same slot. How would you do it?
You could use for example QSignalMapper, QObject::sender() or QButtonGroup to map/identify the sender.
Re: Is there any way to pass default parameters values to any slot?
It should be added that the kind of method declaration jpn presented is a feature of C++ and can be used for all kind of methods in C++. No matter if the method is a Qt slot or just a totally normal method of a simple class.