[Solved] Slider in qml
General and Desktop
6
Posts
2
Posters
4.9k
Views
1
Watching
-
I have made a slider in qml. But I am getting an error, I have a little problem with the logic.
here is my code@
import QtQuick 1.1
Rectangle{
width:250 height:250 color: "grey" property alias maxValue_slider :text1.text property alias minValue_slider :text2.text Rectangle { id: rectangle1 x: 32 y: 15 width: m1.drag.maximumX+20 height: 10 color: "black" Rectangle { id: rectangle2 width: 20 height: 10 radius:25 color: "red" smooth:true MouseArea { id:m1 anchors.fill:parent drag.target: rectangle2 drag.axis: Drag.XAxis drag.minimumX:0 drag.maximumX: maxValue_slider // Need some logic here..// onPositionChanged: {slide.text=maxValue_slider-minValue_slider} } } } Rectangle { id: rectangle3 x: 56 y: 42 width: 84 height: 21 color: "#ffffff" } TextEdit { id: text_edit1 x: 60 y: 43 width: 80 height: 20 font.pixelSize: 12 TextInput { id: slide x: 11 y: 0 width: 80 height: 20 text:text1.text font.pixelSize: 12 } } Text { id: text1 x: 20 y: 31 text: "100" font.pixelSize: 12 } Text { id: text2 x: 147 y: 26 text: "60" font.pixelSize: 12 }
}
@I havebeen trying this for a long time. Thanks for your concern
-
I also tried to use the available Slider online.
@
Slider {
orientation: Qt.Vertical
maximumValue: 25
stepSize: 1
value: 25
valueIndicatorVisible: true
valueIndicatorText: "Volume"
inverted: true
}
@But it gives an error "Slider is instantiated recursively"
Edit: please use @ tags around code sections; Andre
-
@import QtQuick 1.1
Rectangle{width:250 height:250 color: "grey" property alias minValue_slider :text2.text property alias maxValue_slider :text1.text property int i:0 property int k:0 property int j:maxValue_slider-minValue_slider Rectangle { id: rectangle1 x: 32 y: 15 width: 201 height: 10 color: "black" radius:5 function value(minValue_sldier, maxValue_slider) { for (i=minValue_sldier;i<j;i++) k=i } Rectangle { id: rectangle2 width: 20 height: 10 radius:25 color: "red" smooth:true MouseArea { anchors.fill:parent drag.target: rectangle2 drag.axis: Drag.XAxis drag.minimumX:0 drag.maximumX: rectangle1.width-10 onPositionChanged: {text_input1.text=value(minValue_slider,maxValue_slider)} } } } Rectangle { id: rectangle3 x: 56 y: 42 width: 84 height: 21 color: "#ffffff" } TextEdit { id: text_edit1 x: 60 y: 43 width: 80 height: 20 font.pixelSize: 12 TextInput { id: text_input1 x: 11 y: 0 width: 80 height: 20 text:text1.text font.pixelSize: 12 } } Text { id: text1 x: 20 y: 31 text: "50" font.pixelSize: 12 } Text { id: text2 x: 203 y: 31 text: "10" font.pixelSize: 12 }@
I tried implementing it using a function vale but it says cant read variable value.. Could somebody help me