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.
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.
Qt 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()));To copy to clipboard, switch view to plain text mode
J-P Nurmi
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.
You could use for example QSignalMapper, QObject::sender() or QButtonGroup to map/identify the sender.
J-P Nurmi
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.
ricardo (5th May 2009)
Bookmarks