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

RangeSlider does not update position/visualPosition based on from/to changes

    XMLWordPrintable

    Details

    • Commits:
      7ff266ff782b35817d3ecc1a08c3a54bd2c2aa88 (qt/qtdeclarative/dev) 29dfaa92b9d56f5555b511756f5b8ee62aabc0bf (qt/tqtc-qtquickcontrols2/5.15) fd3c67b18318edfbe0a7737e8be1081a775e12df (qt/qtdeclarative/6.2)

      Description

      When we changed from (or to) property of RangeSlider{}, position and visualPosition were not dynamically changed.

       

      Please see the attached example.

       

      IMHO, we need to call updatePosition() in QQuickRangeSlider::setFrom() and 

      QQuickRangeSlider::setTo() like this (it's a just test code)

      shko@shko ~/work/qt_src/qt5/qtquickcontrols2 ((HEAD detached at c0daab494))$ git diff .
      diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
      index 9ad12102e..cefbe5159 100644
      --- a/src/quicktemplates2/qquickrangeslider.cpp
      +++ b/src/quicktemplates2/qquickrangeslider.cpp
      @@ -662,6 +662,11 @@ void QQuickRangeSlider::setFrom(qreal from)
           if (isComponentComplete()) {
               d->first->setValue(d->first->value());
               d->second->setValue(d->second->value());
      +
      +        QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
      +        QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
      +        firstPrivate->updatePosition();
      +        secondPrivate->updatePosition();
           }
       }
       
      @@ -690,6 +695,11 @@ void QQuickRangeSlider::setTo(qreal to)
           if (isComponentComplete()) {
               d->first->setValue(d->first->value());
               d->second->setValue(d->second->value());
      +
      +        QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
      +        QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
      +        firstPrivate->updatePosition();
      +        secondPrivate->updatePosition();
           }
       }
       

       

      Even though there is a setValue() call in QQuickRangeSlider::setFrom() and QQuickRangeSlider::setTo(), updatePosition in setValue() will not be called because there is no value change.

        Attachments

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

          Activity

            People

            Assignee:
            ivan.solovev Ivan Solovev
            Reporter:
            seokhako Seokha Ko
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: