Qt-QML-Slider-滑块-Style-后继
首先了,先把我上篇文章的demo准备好,不过我上次写的被我删除了,这次就重新写了一个,上代码
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
ApplicationWindow {
visible: true
width: 1366
height: 768
title: qsTr("DLSlider")
Slider
{
width: 600
height: 20
x: (parent.width - width)/2
y: (parent.height - height)/2
value: 0.1
stepSize: 0.01
onValueChanged:
{
console.log(value)
} style: SliderStyle
{
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";
} }
groove:Rectangle
{
implicitHeight:8
color:"gray"
radius:8
}
} } }
详细解释大家可以看上一篇博客
这是目前的样式,和上一篇中基本一样,但是不是我要的样式
这里将说下升级版
这样的效果是我想要的效果,上面是进度条,下面是可以拖动的指针,不过呢,能力有限,没有通过编写style实现成功,我用了一个投机取巧的办法来实现。
下面先上我最后的效果截图
上源代码
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
ApplicationWindow {
visible: true
width: 1366
height: 768
title: qsTr("DLSlider") Rectangle
{
id:line_parent
width: 800
height: 20
x: (parent.width - width)/2
y: (parent.height - height)/2
color: "#1ae5ec"
Rectangle
{
id:line_child
height: line_parent.height
anchors.top:parent.top
anchors.left: parent.left
width: parent.width*m_Slider.value
color: "red" }
} Slider
{
id:m_Slider
anchors.top: line_parent.top
anchors.left: line_parent.left
anchors.leftMargin: -5.5
height: line_parent.height*2
width: line_parent.width+11
value: 0.1
stepSize: 0.01
onValueChanged:
{
console.log(value)
} style: SliderStyle
{
handle: Rectangle
{
anchors.horizontalCenter:parent.horizontalCenter
anchors.bottom:parent.bottom
width:11
height:16
color:"transparent"
Image {
width: 11
height: 16
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: -8
source: "qrc:/Images/ppointer.png"
} }
groove:Rectangle
{
color:"transparent"
}
} } }
剩下的需要大家自行对比了,困了,要睡觉了
Qt-QML-Slider-滑块-Style-后继的更多相关文章
- Qt QML referenceexamples attached Demo hacking
/********************************************************************************************* * Qt ...
- 表单(下)-EasyUI Spinner 微调器、EasyUI Numberspinner 数值微调器、EasyUI Timespinner 时间微调器、EasyUI Slider 滑块
EasyUI Spinner 微调器 扩展自 $.fn.validatebox.defaults.通过 $.fn.spinner.defaults 重写默认的 defaults. 微调器(spinne ...
- Qt qml 单例模式
Qt qml 单例模式,没什么好说的,看代码吧.单例模式很适合做全局的配置文件. [示例下载] http://download.csdn.net/detail/surfsky/8539313 [以下是 ...
- Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)
Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果] [功能] 下拉刷新 ...
- qt qml qchart 图表组件
qt qml qchart 图表组件 * Author: Julien Wintz * Created: Thu Feb 13 23:41:59 2014 (+0100) 这玩意是从chart.js迁 ...
- qt qml中PropertyAnimation的几种使用方法
qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...
- easyUI slider滑块,在加载出来后,easyUI slider滑块禁用方法
easyUI slider滑块禁用 如下图easyUI slider滑块,在加载出来后,需要禁止拉动 easyUI slider滑块禁用方法 //禁用$(s1).slider({ disabled:t ...
- 指定Qt程序运行的style,比如fusion(以前没见过QStyleFactory)
转载请注明文章:指定Qt程序运行的style,比如fusion 出处:多客博图 代码很简单,如下: #include <QtWidgets/QApplication> #include ...
- Qt qml的软件架构设计
google: qt qml application architecture 有很多资源. 1 https://www.ics.com/blog/multilayered-architecture- ...
- Qt Quick 常用元素:TabView(选项卡) 与 Slider(滑块)
一.TabView TabView 可以实现类似 Windows 任务管理器的界面,有人叫 TabView 为标签控件,有人又称之为选项卡控件,我们知道它就是这么个东西就行了.现在来介绍 TabVie ...
随机推荐
- IDEA定位开发文件在左边工程中的文件路径
IDEA新公司入职使用第七天,基本快捷键和BUG调试已经搞透了!从最开始的配置到现在的适应确实是一个不小的进步,前几天每天加班太忙没有时间更新博客,明天就是五一假期,现在将刚掌握的一点IDEA技术写出 ...
- javascript-数字转罗马数字
阿拉伯数字与罗马数字转换 罗马数字表示 XXI, 21 个位数举例I, 1 ]II, 2] III, 3] IV, 4 ]V, 5 ]VI, 6] VII, 7] VIII,8 ]IX, 9 ·十位数 ...
- 树莓派图形界面启动chromium并全屏
方法1. 随便一搜都是这种方法 创建文件: /home/pi/.config/autostart/my.desktop 文件名随意, 后缀必须.desktop 文件内容: [Desktop ...
- vue使用element案列
第一步:使用vue创建项目‘ 第二步:在项目添加element cmd:vue add element demo:https://github.com/weibanggang/vuemode.git
- Gradle Goodness: Running Java Applications from External Dependency
With Gradle we can execute Java applications using the JavaExec task or the javaexec() method. If we ...
- Unity 游戏框架搭建 (二十三) 重构小工具 Platform
在日常开发中,我们经常遇到或者写出这样的代码 var sTrAngeNamingVariable = "a variable"; #if UNITY_IOS || UNITY_AN ...
- C#自定义异常
继承自System.ApplicationException类,并使用Exception作为自定义异常类名的结尾 三个构造函数:一个无参构造函数:一个字符串参数的构造函数:一个字符串参数,一个内部异常 ...
- mysql的InnoDB 数据库引擎TableSpace Exists 问题
Mysql数据库报错: ERROR 1813 (HY000): Tablespace '`coll`.`t1`' exists. 原因:在使用InnoDB引擎的数据库中,所有已经存在的表都使在使用In ...
- oracle database 9i/10g/11g 编程艺术 源代码下载
背景 在找这本书的源码,搜到提供的都是需要C币下载的.比较固执(其实是穷). 在这本书的前言中提到源代码可以在 www.appress.com 上下载. 下面是该书在该网站上的链接: https:// ...
- JQuery制作网页—— 第六章 jQuery选择器
1.jQuery选择器:jQuery选择器类似于CSS选择器,用来选取网页中的元素. Eg:$("h3").css("background",&qu ...