[Solved] QSpinBox setMaximum() emits valueChanged() signal, even though value has not changed
Whenever I call setMaximum() in my QSpinBox, I get the valueChanged() signal, even though the value does not change. This causes me to have to put in a kludge, by having a special global flag that I set to ignore the valueChanged() signal before I call setMaximum() and clear the flag afterwards. Either that or I could add a disconnect and connect to the valueChanged() signal. Both solutions are stupid.
Hi, Which version are you using now?
I can not reproduce this bug under Windows XP with Qt4.8.0 and Qt5
class Test : public QObject
void onValueChanged(int i)
int main(int argc, char *argv)
QApplication a(argc, argv);
a.connect(&box, SIGNAL(valueChanged(int)), &t, SLOT(onValueChanged(int)));
I just ran a program similar to yours and could not duplicate the problem either. So I went back to my original code, and determined that there is no problem. What is hapenning is that although I don't change the value, I am setting the maximum lower than the current value. That causes the widget to set the value down to the new maximum, and that causes the valueChanged signal to be emitted.
I hope you don't mind that I wasted your time with this, but at least I know exactly what's going on now.
Be sure and edit your original post to add [Solved] to the title. Thanks!