aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickslider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquickslider.cpp')
-rw-r--r--src/quicktemplates2/qquickslider.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index b5bf5e52..8628f981 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -430,33 +430,6 @@ void QQuickSlider::setSnapMode(SnapMode mode)
}
/*!
- \since QtQuick.Controls 2.2 (Qt 5.9)
- \qmlproperty bool QtQuick.Controls::Slider::live
-
- This property holds whether the slider provides live updates for the \l value
- property while the handle is dragged.
-
- The default value is \c true.
-
- \sa value, valueAt()
-*/
-bool QQuickSlider::live() const
-{
- Q_D(const QQuickSlider);
- return d->live;
-}
-
-void QQuickSlider::setLive(bool live)
-{
- Q_D(QQuickSlider);
- if (d->live == live)
- return;
-
- d->live = live;
- emit liveChanged();
-}
-
-/*!
\qmlproperty bool QtQuick.Controls::Slider::pressed
This property holds whether the slider is pressed.
@@ -572,7 +545,37 @@ void QQuickSlider::setHandle(QQuickItem *handle)
qreal QQuickSlider::valueAt(qreal position) const
{
Q_D(const QQuickSlider);
- return d->from + (d->to - d->from) * position;
+ const qreal value = d->from + (d->to - d->from) * position;
+ if (qFuzzyIsNull(d->stepSize))
+ return value;
+ return qRound(value / d->stepSize) * d->stepSize;
+}
+
+/*!
+ \since QtQuick.Controls 2.2 (Qt 5.9)
+ \qmlproperty bool QtQuick.Controls::Slider::live
+
+ This property holds whether the slider provides live updates for the \l value
+ property while the handle is dragged.
+
+ The default value is \c true.
+
+ \sa value, valueAt()
+*/
+bool QQuickSlider::live() const
+{
+ Q_D(const QQuickSlider);
+ return d->live;
+}
+
+void QQuickSlider::setLive(bool live)
+{
+ Q_D(QQuickSlider);
+ if (d->live == live)
+ return;
+
+ d->live = live;
+ emit liveChanged();
}
/*!