Qt/QML学习-SpinBox

QML学习

main.qml

复制代码
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("SpinBox")

    SpinBox {
        id: spinBox
        anchors.centerIn: parent
        from: 0
        to: 100
        value: 50
        stepSize: 20
        editable: true
        background: Rectangle {
            implicitWidth: 200
            implicitHeight: 100
            border.width: 1
        }
        contentItem: Rectangle {
            TextInput {
                anchors.centerIn: parent
                text: spinBox.value
                font.pointSize: 30
                readOnly: !spinBox.editable
            }
        }
        down {
            indicator: Rectangle {
                implicitWidth: spinBox.background.width / 4
                implicitHeight: spinBox.background.height
                border.width: 1
                color: enabled?
                        spinBox.down.pressed? "gray": "white":
                        "lightGray"
                Text {
                    anchors.centerIn: parent
                    font.pointSize: 30
                    text: "-"
                }
            }
        }
        up {
            indicator: Rectangle {
                implicitWidth: spinBox.background.width / 4
                implicitHeight: spinBox.background.height
                x: spinBox.background.width - width
                border.width: 1
                color: enabled?
                        spinBox.up.pressed? "gray": "white":
                        "lightGray"
                Text {
                    anchors.centerIn: parent
                    font.pointSize: 30
                    text: "+"
                }
            }
        }
    }
}

演示

视频讲解

相关推荐
DevNo20 分钟前
我的医学考研学习品牌接触记录
学习·考研
传奇开心果编程33 分钟前
【ArkUI进阶练中学】第9课:分布式能力与多设备协同
学习·ui·华为·harmonyos
shangan_336 分钟前
C语言学习
c语言·开发语言·学习
每天题库43 分钟前
汽车维修工考试题库:真题错题复盘与高频考点清单
学习·安全·考试·题库·考证
阳光九叶草LXGZXJ1 小时前
达梦数据库-学习-71-存过执行过程中重建存过影响验证
linux·运维·数据库·sql·学习
小O的算法实验室2 小时前
IEEE TEVC,搜索方向学习加速大规模煤矿综合能源系统调度中的进化优化
学习·能源
zhangrelay11 小时前
机械臂末端规划智能模型的误区演示
linux·笔记·学习·ubuntu·ros2
织码weavecodes13 小时前
培训平台部署备份与容灾:从三服务交付到可恢复运行
大数据·学习·开源软件
JWASX15 小时前
Java 转 go 学习 - 类型转换
学习·golang
小淮AI17 小时前
在职医生备考主治医师,我的资料搭配思路
学习