如何在Ubuntu QML应用中实现一个垂直的Slider
来源:互联网 发布:安卓看电影软件 编辑:程序博客网 时间:2024/05/16 01:02
我们在使用Ubuntu SDK中的Slider的时候,我们发现,它没有orientation的属性尽管在Qt官方网站的slider是有这个属性的。在默认的情况下,这个Slider是水平的。那么我们该如实现这个呢?
我们的任何一个QML Item都有一个属性叫做rotation。我们可以通过这个属性来得到一个旋转90度的水平Slider。这样我们就可以用如下的代码来实现了:
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" /* This property 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(50) height: units.gu(75) 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.toFixed(2) } minimumValue: -3.14 maximumValue: 3.14// rotation: 90// orientation: Qt.Horizontal value: 0.0 live: true } }}
这里创建了连个Slider,一个是是水平的(默认情况下的),另外一个是垂直的(旋转90度的)。显示的结果如下:
0 1
- 如何在Ubuntu QML应用中实现一个垂直的Slider
- 如何在Ubuntu QML应用中实现ComboBox的功能
- 如何在Ubuntu QML应用中实现MultipleSelectionListView
- 如何在QML应用中实现一个Splash画面
- 如何在Ubuntu QML应用中判断应用的方位(landscape或portrait)
- 如何在Ubuntu QML应用中使用Push Notification
- 如何在Ubuntu QML应用中播放音乐
- 如何在Ubuntu QML应用中播放视频
- 如何在Ubuntu QML应用中震动(vibration)
- 如何在Ubuntu QML应用中进行语言录音
- 在Ubuntu QML应用中实现Particle特效
- 如何在QML应用中创建一个Context Menu
- 如何在Ubuntu QML应用中设计像微信对话那样的UI
- 在QML应用中如何实现drag and drop功能
- 如何在QML应用中得到一个Item的所有属性,信号及方法
- 如何在QML应用中设计自己的Dialog
- 如何在QML应用中创建类似ContextMenu的控件
- 如何在QML应用中读写文件
- 编程之美3.1—字符串移位包含问题
- java 发送post和get请求源码详解
- Android 正则表达式g
- C#中的Invoke
- 关于xml总结(二)
- 如何在Ubuntu QML应用中实现一个垂直的Slider
- GCDAsyncSocket接受数据丢包的问题
- 我用DW也有几年了,真不知道你说的这些代码是什么?不是快捷键吧?
- sax、dom、pull解析xml
- Android图片的选取和拍照
- ODBC+C/C++ 数据库操作
- 有理想的程序员必须知道的15件事
- 安装Package Control
- UIAlertController