QSlider valueChanged connection not working
-
I have written a widget which I use in two places:

At the right of the display there are three controls, two spinners and a pushbutton. The spinners are used to set common attributes for the widgets, the maximum and minimum values to show.In the class I have defined static pointers so that each graphic can access the values of the controls, in the constructor I have code like:
truth::mspSpinMax = new QSpinBox(pParent); truth::mspSpinMax->setSingleStep(truth::mscuint16StepSize - 1); truth::mspSpinMax->setMaximum(truth::msintMaximum); truth::mspSpinMax->setValue(truth::msintMaximum); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } );The problem is that the signals are not making it to the slots, in that the lambda slots I am using never get called. What could be wrong?
-
@J-Hilk , @jsulm , something very strange is happening, I thought I would try adding another connection:
truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } ); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { qDebug() << intValue; } );Now the first connection is working and the debugger stops in the slot...the second connection doesn't work and no debug output appears.
It has to be a bug because with both connections the first connection works, if I comment out the second it doesn't work.
Qt Creator 4.4.1
Based on Qt 5.9.2 (MSVC 2015, 32 bit)Unfortunately I cannot upgrade Qt or MSVC, these are the versions I have to work with. Could it be something to do with the static member references in the first slot?
-
I have written a widget which I use in two places:

At the right of the display there are three controls, two spinners and a pushbutton. The spinners are used to set common attributes for the widgets, the maximum and minimum values to show.In the class I have defined static pointers so that each graphic can access the values of the controls, in the constructor I have code like:
truth::mspSpinMax = new QSpinBox(pParent); truth::mspSpinMax->setSingleStep(truth::mscuint16StepSize - 1); truth::mspSpinMax->setMaximum(truth::msintMaximum); truth::mspSpinMax->setValue(truth::msintMaximum); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } );The problem is that the signals are not making it to the slots, in that the lambda slots I am using never get called. What could be wrong?
@SPlatten said in QSlider valueChanged connection not working:
in that the lambda slots I am using never get called
How did you prove that?
-
I have written a widget which I use in two places:

At the right of the display there are three controls, two spinners and a pushbutton. The spinners are used to set common attributes for the widgets, the maximum and minimum values to show.In the class I have defined static pointers so that each graphic can access the values of the controls, in the constructor I have code like:
truth::mspSpinMax = new QSpinBox(pParent); truth::mspSpinMax->setSingleStep(truth::mscuint16StepSize - 1); truth::mspSpinMax->setMaximum(truth::msintMaximum); truth::mspSpinMax->setValue(truth::msintMaximum); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } );The problem is that the signals are not making it to the slots, in that the lambda slots I am using never get called. What could be wrong?
are you mixing something up here ?
truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } );the return type of
QObject::connectis aQMetaObject::Connectionthat allows for a implicit conversion to bool and therefore int.You seem to want to assign it to a int value
mscnSpinMaxValueChanged? -
@SPlatten said in QSlider valueChanged connection not working:
in that the lambda slots I am using never get called
How did you prove that?
-
are you mixing something up here ?
truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } );the return type of
QObject::connectis aQMetaObject::Connectionthat allows for a implicit conversion to bool and therefore int.You seem to want to assign it to a int value
mscnSpinMaxValueChanged? -
@SPlatten said in QSlider valueChanged connection not working:
in that the lambda slots I am using never get called
How did you prove that?
-
@J-Hilk , @jsulm , something very strange is happening, I thought I would try adding another connection:
truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } ); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { qDebug() << intValue; } );Now the first connection is working and the debugger stops in the slot...the second connection doesn't work and no debug output appears.
It has to be a bug because with both connections the first connection works, if I comment out the second it doesn't work.
Qt Creator 4.4.1
Based on Qt 5.9.2 (MSVC 2015, 32 bit)Unfortunately I cannot upgrade Qt or MSVC, these are the versions I have to work with. Could it be something to do with the static member references in the first slot?
-
@J-Hilk , @jsulm , something very strange is happening, I thought I would try adding another connection:
truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { if ( truth::mspBtnUpdate != nullptr ) { truth::mspBtnUpdate->setEnabled(truth::msintLastMax != intValue); } } ); truth::mscnSpinMaxValueChanged = QObject::connect(truth::mspSpinMax, QOverload<int>::of(&QSpinBox::valueChanged), [this](int intValue) { qDebug() << intValue; } );Now the first connection is working and the debugger stops in the slot...the second connection doesn't work and no debug output appears.
It has to be a bug because with both connections the first connection works, if I comment out the second it doesn't work.
Qt Creator 4.4.1
Based on Qt 5.9.2 (MSVC 2015, 32 bit)Unfortunately I cannot upgrade Qt or MSVC, these are the versions I have to work with. Could it be something to do with the static member references in the first slot?