qml学习-------------Slider(滑块)
2015-09-22 13:36
288 查看
Slider跟其他的控件一样,可以通过SliderStyle来设置滑块的风格。
import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 Rectangle{ width: 320; height: 240; color: "lightgray"; Row{ anchors.fill: parent; spacing: 20; Column{ width: 200; spacing: 16; Text{ id:sliderStat; color: "blue"; text:"current - 0.1"; } Slider{ width: 200; height: 30; stepSize: 0.01; value: 1; onValueChanged: { sliderStat.text = "current - " + value; } } Slider{ width: 200; height: 30; minimumValue: 0; maximumValue: 100; stepSize: 1; value: 50; tickmarksEnabled: true; } Slider{ id: customGrooveAndHandle; width: 200; height: 30; stepSize: 0.1; tickmarksEnabled: true; value: 0; 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: 34; height: 34; radius: 12; } } } Slider{ id: customPanel; width: 200; height: 36; stepSize: 0.1; value: 0; tickmarksEnabled: true; 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: 34; height: 34; radius: 12; Text{ anchors.centerIn: parent; text: control.value; color: "red"; } } panel: Rectangle{ anchors.fill: parent; radius: 4; color: "lightsteelblue"; Loader{ id: grooveLoader; anchors.centerIn: parent; sourceComponent: groove; } Loader{ id: handleLoader; anchors.verticalCenter: grooveLoader.verticalCenter; x: Math.min(grooveLoader.x + (control.value * grooveLoader.width)/(control.maximumValue - control.minimumValue) , grooveLoader.width - item.width ); sourceComponent: handle; } } } } } Slider{ width: 30; height: 200; orientation: Qt.Vertical; stepSize: 0.1; value: 0.2; tickmarksEnabled: true; } } }
相关文章推荐
- No EditorOptionDefinition Export Found Error的问题
- 三维气象要素场--Unity3d篇
- Nginx负载均衡配置实例详解
- IIS建立.net framework4 应用程序池HTTP 错误 500.21 - Internal Server Error处理程序“NickLeeCallbackHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler”
- iOS 集成银联支付(绕过文档的坑,快速集成)-转
- c++设置输出精度
- 数组、字典转化为json字符串
- Win10系统IE出错提示“internet explorer已停止工作”怎么办?
- Android ButterKnife注入框架 使用
- UIImagePickerController 中文
- LintCode "Sort Letters by Case"
- spring框架模块分析
- 单链表面试题
- (模板) NTT long long 版
- html点击文字显示图片
- 【Java doc】java.util.concurrent.ThreadPoolExecutor
- 设计模式之组合模式
- Permutations
- 解决valgrind线程数不够的错误:no free slots available Increase VG_N_THREADS, rebuild and try again.
- mysql 5.6 utf-8 编码设置