Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
4.7.0, 5.6.1, 5.9.1
-
None
-
Ubuntu 10.04, 4 GB RAM, Intel Core 2 Duo CPU T7500 @ 2.20 GHz, available disk space: 54 GB.
Description
When the slots that handle the valueChanged() signal for a QSpinBox are long-running, the QSpinBox will increment the value multiple times, causing not only the value to be incorrect but also recursion as those slots are called repeatedly.
On my machine (which is about average specs), clicking the "up" arrow on the QSpinBox when running the following program will cause the value to increment from 1 (which is expected) to 4 values per click.
main.cpp
#include <QApplication> #include <QtGui> #include <QtTest> class MyWindow : public QMainWindow { Q_OBJECT public: explicit MyWindow(QWidget *parent = NULL) : QMainWindow(parent) { QSpinBox *spin = new QSpinBox; connect(spin, SIGNAL(valueChanged(int)), SLOT(OnSpinBoxChanged())); setCentralWidget(spin); } private slots: void OnSpinBoxChanged() { qDebug() << "OnSpinBoxChanged()"; QTest::qSleep(3000); } }; #include "main.moc" int main(int argc, char **argv) { QApplication app(argc, argv); MyWindow win; win.show(); return app.exec(); }