Reset the QML Slider value
-
Hello,
I have started practicing the QML since few months, i was unable to figure out a small implementation
I want to reset the QML slider value to 0 when the user does not drag's the slider handle till the end of the slider (from the below posted code snipped i want to reset the slider handle to 0 if he does not drag till 100).
I am trying to use the pressed property of slider to reset the handle to value 0 but it is not happening, not getting what i am missing.Can someone help with the following code snippet?
import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Row { Slider { id:slider from: 1 value: 25 to: 100 onVisualPositionChanged: { if(slider.pressed != false){ console.error("in if===========================",Math.floor(slider.value)) } else{ slider.value = 0 } } } Label { text: Math.floor(slider.value) } } }Thanks in advance !!
Regard's,
#A -
Hello,
I have started practicing the QML since few months, i was unable to figure out a small implementation
I want to reset the QML slider value to 0 when the user does not drag's the slider handle till the end of the slider (from the below posted code snipped i want to reset the slider handle to 0 if he does not drag till 100).
I am trying to use the pressed property of slider to reset the handle to value 0 but it is not happening, not getting what i am missing.Can someone help with the following code snippet?
import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Row { Slider { id:slider from: 1 value: 25 to: 100 onVisualPositionChanged: { if(slider.pressed != false){ console.error("in if===========================",Math.floor(slider.value)) } else{ slider.value = 0 } } } Label { text: Math.floor(slider.value) } } }Thanks in advance !!
Regard's,
#A@AROH said in Reset the QML Slider value:
I want to reset the QML slider value to 0 when the user does not drag's the slider handle till the end of the slider (from the below posted code snipped i want to reset the slider handle to 0 if he does not drag till 100).
Wouldn't the following do what you want?
onPressedChanged: { if (!pressed && value !== to) value = from; } -
A AROH has marked this topic as solved on
-
@AROH said in Reset the QML Slider value:
I want to reset the QML slider value to 0 when the user does not drag's the slider handle till the end of the slider (from the below posted code snipped i want to reset the slider handle to 0 if he does not drag till 100).
Wouldn't the following do what you want?
onPressedChanged: { if (!pressed && value !== to) value = from; }