Reputation: 89
I am doing a simple slider project just to understand how sliders work in QML.
I am using the slider from Qt.labs.controls
I looked at their documentation and there are only two methods.
void decrease()
and void increase()
All I want to do is display the value corresponding to the slider position. I can't find any signal or method that tells me if the current position changed or something like that. Am I looking in the right place? Or Do I have to write everything from scratch to make my simple project work?
Update: I am using QT5.6 should I use higher version for this
Upvotes: 0
Views: 3212
Reputation: 9718
You specifically mentioned labs, which means you're probably using QtQuick 2. There's been a lot of important developments of the Controls components since Qt5.6, so it would be advisable to upgrade if the intention is to continue using QtQuick 2.
http://doc.qt.io/qt-5/qml-qtquick-controls2-slider.html gives the latest docs. Note that the widget was updated in Qt5.7, and that the current import command is import QtQuick.Controls 2.1
.
The latest Qt is 5.8, in which the Slider supports both position
, and value
.
position
: the slider's position, from 0 to 1.value
: the output value mapped from position
onto the scale [from
, to
]Upvotes: 1
Reputation: 111
You can use value property of that control. Every qml property has implicit signal handler.For ex: for value property you will have signal onValueChanged. For your simple project you can also use slider control from QtQuick.Controls. Just import QtQuick.Controls 1.4 in your qml file.
Upvotes: 0