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

演示

视频讲解

相关推荐
C语言扫地僧33 分钟前
RPC 框架项目剖析
c++·网络协议·学习·rpc
三少爷的甲壳虫35 分钟前
Python&C
学习
DKPT1 小时前
计算机网络之路由协议(自治系统)
开发语言·笔记·学习·计算机网络·算法
虾球xz1 小时前
游戏引擎学习第119天
学习·游戏引擎
m0_594526301 小时前
基于 PyQt5 实现分组列表滚动吸顶效果
开发语言·python·qt
追烽少年x3 小时前
Qt 中的线程池QRunnable和QThreadPool
qt
日记成书3 小时前
详细介绍嵌入式硬件设计
嵌入式硬件·深度学习·学习
技术小齐3 小时前
网络运维学习笔记 022 HCIA-Datacom新增知识点03园区网典型组网架构及案例实战
运维·网络·学习
hxung5 小时前
MySQL面试学习
学习·mysql·面试
weixin_502539855 小时前
rust学习笔记5-所有权机制
笔记·学习·rust