I'm using RangeSlider
for my project in QML. My range slider code is as follows:
RangeSlider {
id: rangeSLider
first.value: 0.0
second.value: 1.0
anchors.horizontalCenter: parent.horizontalCenter
width: 275
onFirstChanged: console.log("Change")
}
When I run this code, I get an error. The error is:
Cannot assign to non-existent property "onFirstChanged"
I want to change a text in a parent QML file. So I thought I'd use onFirstChange
and onSecondChange
functions to do that, but it did not work.
How can I do this?
For future reference, please provide a MCVE. It helps other people help you a lot easier. In this case, I'd like to see a QML snippet I could look at using qmlscene (including showing what imports you use, this is important!)
Assuming you are using QtQuickControls 2's RangeSlider, The first
and second
properties are constant. This means that those values themselves do not change, but rather, the members of those properties (e.g. first.value) change instead. So you want to connect the change signal to the first
/second
/ instance, rather than on the RangeSlider itself, something like this:
RangeSlider {
from: 1
to: 100
first.value: 30
second.value: 70
Connections {
target: first
onValueChanged: console.log("first.value changed!")
}
}