How to implement a vertical slider in Ubuntu qml applications

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.