[SOLVED] Slider Issue
-
Hi all,
I'm new to these forums but they seem like a great place to get help. I am having this issue where I'm accidentally changing the values of my sliders when I press on their grooves to slide the app window up or down. Is there any way to restrict them such that their values can only be changed by their handles?
I have tried a few things involving the activeFocusOnPress and pressed properties as well as child MouseAreas but nothing seems to work. Any help would be greatly appreciated! -
Hi and Welcome to the Qt Forum,
You can use the "enabled":http://qt-project.org/doc/qt-5/qml-qtquick-item.html#enabled-prop property to enable/disable the Slider.
Can you explain what you do you mean by "slide the app window up or down" ? Can you post a sample code which explains it ? -
Sure, and thanks for the welcoming :)
So my app page is contained within a flickable object like this
@Flickable{
visible: !joinOn
anchors.fill: parent
contentWidth: appWidth
contentHeight: childrenRect.height
flickableDirection: Flickable.VerticalFlick
boundsBehavior: Flickable.StopAtBounds
//... the rest of the page
}
@Within the page I have several slider objects stacked on each other like so:
@Slider {
id: monthSlider
width: appWidth
height: oneLineHeight
}
Slider {
id: daySlider
width: appWidth
height: oneLineHeight
achors.top: monthSlider.bottom
anchors.topMargin: spacing
}
Slider {
id: yearSlider
width: appWidth
height: oneLineHeight
achors.top: daySlider.bottom
anchors.topMargin: spacing
}@My issue is that as I'm trying to navigate the page vertically, by swiping my fingers, I sometimes press on the slider grooves and thereby change change the slider values: which is what I don't want to happen. I want the sliders to only be able to change value when the handle is pressed, which is why I tried setting the enabled property to enabled: pressed. But that doesn't work. I've also tried activeFocusOnPress: pressed but that doesn't work either. And lastly I tried using a customized mouse area above my sliders but I couldn't work that out.
-
You can disable the Sliders when the user is "flicking":http://qt-project.org/doc/qt-5/qml-qtquick-flickable.html#flicking-prop.
-
Ah. Thank you so much that's perfect!