QML Slider : handle and mouse cursor -
i created slider in item , customized in following code :
item { id: item1 x: 0 y: 0 width: 200 height: parent.height rectangle { id: background anchors.fill: parent; color:qt.rgba(0.9,0.9,0.9,1); } slider { anchors.centerin: parent orientation: qt.vertical height: parent.height style: sliderstyle { groove: rectangle { implicitwidth: 200 implicitheight: 8 color: "gray" radius: 8 } handle: rectangle { anchors.centerin: parent color: control.pressed ? "white" : "lightgray" border.color: "gray" border.width: 2 width: 20 height: 20 radius: 6 } } } }
the problem appears when change size of handle have wider high, change in handle :
width: 20 height: 80 //the height changed instead of width think //it's because vertical slider
and then, when move handle, doesn't stay under mouse cursor there offset between two.
how fix that?
the slider internally rotated 90 degrees when orientation vertical, you'll need set width
instead of height
. in other words, style handle assuming slider horizontal, , rest work...
... except mouse offset bug ran into. appears use case isn't auto-tested. please submit bug report @ bugreports.qt.io.
Comments
Post a Comment