Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.0
-
None
-
Qt 5.9.0
Qt Quick Controls 2
-
0d851ddab069bd4373e90beacba0efa38ec021bb
Description
When using a SpinBox QtQuick Controls 2 component, the signal valueModified() should emit when the value is being updated by a user interaction.
When the plus or minus button is clicked, this signal is emitted.
But when pressing and holding either buttons (which activates the internal timer(Event)), the valueModified() signal is not emitted.
In the Qt Quick Controls, Quick Template 2, the function void QQuickSpinBox::timerEvent(QTimerEvent *event) should check whether it has triggered an updated value (as happens in all other user interaction handlers: handleRelease, wheelEvent, keyPressEvent, ...)
Suggestion code change:
void QQuickSpinBox::timerEvent(QTimerEvent *event) { Q_D(QQuickSpinBox); QQuickControl::timerEvent(event); if (event->timerId() == d->delayTimer) { d->startPressRepeat(); } else if (event->timerId() == d->repeatTimer) { if (d->up->isPressed()) increase(); else if (d->down->isPressed()) decrease(); } }
to
void QQuickSpinBox::timerEvent(QTimerEvent *event) { Q_D(QQuickSpinBox); QQuickControl::timerEvent(event); if (event->timerId() == d->delayTimer) { d->startPressRepeat(); } else if (event->timerId() == d->repeatTimer) { const int oldValue = d->value; if (d->up->isPressed()) increase(); else if (d->down->isPressed()) decrease(); if (d->value != oldValue) emit valueModified(); } }
QML Workaround, add following to a SpinBox component:
onValueChanged: { if(up.pressed || down.pressed) valueModified() // Press and hold + or - }
Attachments
For Gerrit Dashboard: QTBUG-61426 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
197510,3 | QQuickSpinBox: emit valueModified() on long press | 5.9 | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |