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: "+"
                }
            }
        }
    }
}

演示

视频讲解

相关推荐
承渊政道11 分钟前
【动态规划算法】(斐波那契数列模型详解)
数据结构·c++·学习·算法·leetcode·macos·动态规划
南境十里·墨染春水16 分钟前
linux学习进展 网络基础
linux·网络·学习
RunningBComeOn19 分钟前
001学习笔记
学习
东京老树根22 分钟前
SAP学习笔记 - BTP SAP Build08 - BPA Condition,Decision Table
笔记·学习
71-322 分钟前
C语言练习——数组的练习(涉及顺序、二分查找,冒泡排序)
c语言·笔记·学习·排序算法·查找算法
深蓝海拓25 分钟前
基于QtPy (PySide6) 的PLC-HMI工程项目(十二)最后的工作
网络·笔记·python·学习·pyqt·plc
承渊政道26 分钟前
【动态规划算法】(从入门到精通:路径问题)
数据结构·c++·学习·算法·leetcode·macos·动态规划
王的宝库27 分钟前
【Ansible】变量与敏感数据管理:Vault 加密 + Facts 采集详解
笔记·学习·ansible
星幻元宇VR2 小时前
VR机动车模拟驾驶系统助力交通安全科普
科技·学习·安全·生活·vr
大龄程序员狗哥9 小时前
第25篇:Q-Learning算法解析——强化学习中的经典“价值”学习(原理解析)
人工智能·学习·算法