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

演示

视频讲解

相关推荐
结衣结衣.18 分钟前
走进机器学习:新手必看的完整入门指南
人工智能·python·学习·机器学习
xian_wwq33 分钟前
【学习笔记】探讨大模型应用安全建设系列5——供应链安全与数据防护
笔记·学习
solicitous1 小时前
学习了解充电桩协议OCPP-架构与拓扑
学习·充电桩
迷枫7121 小时前
DM8 读写分离集群学习总结:从部署规划到扩容排查
数据库·学习
Harm灬小海1 小时前
【云计算学习之路】学习Centos7系统:服务搭建(VSFTP)
linux·运维·服务器·学习·云计算
Ws_2 小时前
C# 学习 Day1
开发语言·学习·c#
z200509302 小时前
【linux学习】linux工具篇(下)
linux·学习
星夜夏空992 小时前
STM32单片机学习(17) —— 串口外设中断
stm32·单片机·学习
魔法阵维护师2 小时前
从零开发游戏需要学习的c#模块,第二十一章(精灵动画 —— 让角色走起来)
学习·游戏·c#
郝学胜-神的一滴2 小时前
Qt 高级开发 011: 跨线程信号槽实战
开发语言·c++·qt·程序人生·开源软件·用户界面