event connect not honoring default value of handler
-
I have a button that I have tied to an event that has a default value. like so:
here's the event:
connect(gaugeDivisions1SpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Window::divisions1Changed);here's the slot definition:
private slots: void divisions1Changed(bool color = false);and here's the actual event code:
void Window::divisions1Changed(bool Color) { QColor pColor = Qt::black; if (Color) pColor = getColor(); renderArea->setDivisions1(gaugeDivisions1SpinBox->value(), gaugeDivisions1InnerRadiusSpinBox->value(), gaugeDivisions1OuterRadiusSpinBox->value(), gaugeDivisions1WidthSpinBox->value(), pColor); }When I click the spinbox, the Color bool value comes across as true. but if I call the event otherwise with no parameter...Color is correctly assumed false. What am I doing wrong? Anyone have any ideas?
-
I have a button that I have tied to an event that has a default value. like so:
here's the event:
connect(gaugeDivisions1SpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Window::divisions1Changed);here's the slot definition:
private slots: void divisions1Changed(bool color = false);and here's the actual event code:
void Window::divisions1Changed(bool Color) { QColor pColor = Qt::black; if (Color) pColor = getColor(); renderArea->setDivisions1(gaugeDivisions1SpinBox->value(), gaugeDivisions1InnerRadiusSpinBox->value(), gaugeDivisions1OuterRadiusSpinBox->value(), gaugeDivisions1WidthSpinBox->value(), pColor); }When I click the spinbox, the Color bool value comes across as true. but if I call the event otherwise with no parameter...Color is correctly assumed false. What am I doing wrong? Anyone have any ideas?
@RobbieP said in event connect not honoring default value of handler:
Signalvoid QSpinBox::valueChanged(int i)--- and yourconnect()toQOverload<int>::of(&QSpinBox::valueChanged)---sendsias parameter, you let that through to your slotvoid divisions1Changed(bool color = false)as the value ofcolor. Change your slot to match, or munch theiparameter in a lambda.