View Full Version : Is there any way to pass default parameters values to any slot?
ricardo
3rd May 2009, 13:50
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.
class Foo
{
public slots:
void UpdateCameraZoom(qreal level = 1.0);
};
void Foo::UpdateCameraZoom(qreal level)
{
// ...
}
connect(ui.actionZoom_1X, SIGNAL(triggered()), d, SLOT(UpdateCameraZoom()));
ricardo
3rd May 2009, 14:11
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.
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.
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.