diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-11-06 14:02:21 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-11-06 14:02:21 +0100 |
commit | c39b126a77e27296ef82a1634753c775cc5a93fb (patch) | |
tree | 235d9568e21e59b7c70f8be81518c3ea184cf552 /src/quicktemplates2/qquickslider.cpp | |
parent | dc2603562a36241c9beac0c9c4c08bcbfed7b6a2 (diff) | |
parent | 430fe83ecb7106118cbebd735637aee9e9253914 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
src/quicktemplates2/qquickabstractbutton_p.h
src/quicktemplates2/qquickbuttongroup_p.h
src/quicktemplates2/qquickrangeslider.cpp
src/quicktemplates2/qquickrangeslider_p.h
src/quicktemplates2/qquickswipeview_p.h
src/quicktemplates2/qquicktextarea.cpp
src/quicktemplates2/qquicktextarea_p.h
src/quicktemplates2/qquicktextfield_p.h
Change-Id: I7cba8783b1dd85a4db534222e36572ee05dd01d0
Diffstat (limited to 'src/quicktemplates2/qquickslider.cpp')
-rw-r--r-- | src/quicktemplates2/qquickslider.cpp | 59 |
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(); } /*! |