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

演示

视频讲解

相关推荐
肥肠可耐的西西公主23 分钟前
后端(fastAPI)学习笔记(CLASS 1):扩展基础
笔记·学习·fastapi
對玛祷至昏44 分钟前
算法学习路径
学习·算法·排序算法
qq_386322695 小时前
华为网路设备学习-32(BGP协议 七)路由反射器与联邦
网络·学习
萘柰奈5 小时前
Unity学习----【进阶】Addressables(二)--加载资源与打包及更新
学习·unity
liliangcsdn8 小时前
Leiden社区发现算法的学习和示例
学习·数据分析·知识图谱
FPGAI8 小时前
Qt编程之信号与槽
开发语言·qt
DKPT9 小时前
JVM中如何调优新生代和老生代?
java·jvm·笔记·学习·spring
phltxy9 小时前
JVM——Java虚拟机学习
java·jvm·学习
只因在人海中多看了你一眼10 小时前
B.50.10.09-RPC核心原理与电商应用
qt·网络协议·rpc
yudiandian201412 小时前
【QT 5.12.12 下载 Windows 版本】
开发语言·qt