Solved Slot with default argument
-
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. -
Try
QObject::connect(class1, &MyClass1::newData, [=](){ class2->updateValue();});
-
@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?
-
I do not know :-)
-
There are two methods possible for connect
-
Hi,
It was possible and I would think it's still possible with the SIGNAL, SLOT Macros.
-Michael. -
-
I would strongly recommend the Qt5 way though (using lambdas)!