Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61426

SpinBox press and hold + or - does not trigger valueModified

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.1
    • 5.9.0
    • Quick: Controls 2
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            bartel Bartel Eerdekens
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes