When we were using the slider in the Ubuntu SDK, we found that it had no orientation properties though the slider on the official QT site had this attribute. In the default case, the slider is horizontal. So what do we do with this?
Any one of our QML item has a property called rotation. We can use this property to get a horizontal slider that rotates 90 degrees. This allows us to implement the following code:
Import QtQuick 2.0import ubuntu.components 1.1/*! \brief MainView with a Label and Button Elements.*/mainview {//ObjectName for functional testing purposes (autopilot- QT5) ObjectName: "MainView"//note! ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Slider.liu-xiao-guo"/* The enables the application to change orientation when the device is rotated. The default is False. *///automaticorientation:true//Removes the old toolbar and enables new features of the new header. Usedeprecatedtoolbar:false width:units.gu (height:units.gu) page {title:i18n.tr ("Slider") Slider {X:PARENT.WIDTH/2-width/2 Y:PARENT.HEIGHT/2-HEIGHT/2 function Formatvalue (v ) {return v.tofixed (2)} MinimumValue: -3.14 maximumvalue:3.14//rotation:90 value:0.0 Live:true} Slider { X:PARENT.WIDTH/2-WIDTH/2 Y:PARENT.HEIGHT/2-HEIGHT/2 function Formatvalue (v) {return v.tof Ixed (2)} MinimumValue: -3.14 maximumvalue:3.14//rotation:90//Orientation: Qt.horizontal value:0.0 Live:true}}}
Here a slider is created, one is horizontal (by default) and the other is vertical (rotated 90 degrees). The results shown are as follows:
How to implement a vertical slider in Ubuntu qml applications