Slot with default argument
-
wrote on 7 Nov 2016, 14:49 last edited by
Hi,
i thought that i could connect a signal to a slot with a default argument. Like said in the docMy signal:
void newData();
My slot:
void updateValue(bool all = false);
Connect:
QObject::connect(class1, &MyClass1::newData, class2, &MyClass2::updateValue);
When i want to connect them i get
C2338: The slot requires more arguments than the signal provides. -
wrote on 7 Nov 2016, 14:53 last edited by
Try
QObject::connect(class1, &MyClass1::newData, [=](){ class2->updateValue();});
-
wrote on 7 Nov 2016, 15:16 last edited by
I do not know :-)
-
@BjornW
Yes, connect to lambda function works perfectly.But i thought that connect to a slot with default argument was previos possible. Or am i wrong with that?
wrote on 7 Nov 2016, 15:23 last edited byThere are two methods possible for connect
-
wrote on 7 Nov 2016, 15:25 last edited by m.sue 11 Aug 2016, 09:25
Hi,
It was possible and I would think it's still possible with the SIGNAL, SLOT Macros.
-Michael. -
Hi,
It was possible and I would think it's still possible with the SIGNAL, SLOT Macros.
-Michael. -
wrote on 8 Nov 2016, 08:01 last edited by
I would strongly recommend the Qt5 way though (using lambdas)!
5/8