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

演示

视频讲解

相关推荐
2501_920627615 小时前
Flutter 框架跨平台鸿蒙开发 - 古文学习应用
学习·flutter·harmonyos
环黄金线HHJX.6 小时前
【吧里BaLi社区】
开发语言·人工智能·qt·编辑器
江苏世纪龙科技8 小时前
【世纪龙科技】当智能网联汽车教学遇上“数字孪生”
学习
杰尼龟3689 小时前
Convince Develop 学习笔记
笔记·学习
不早睡不改名@9 小时前
Netty源码分析---Reactor线程模型深度解析(二)
java·网络·笔记·学习·netty
婷婷_1729 小时前
【PCIe验证每日学习·Day25】PCIe 电源管理机制(L0s/L1/L2/L3)全解析
网络·学习·程序人生·芯片·电源管理·pcie 验证·低功耗状态
東雪木10 小时前
Java学习——一访问修饰符(public/protected/default/private)的权限控制本质
java·开发语言·学习·java面试
星幻元宇VR11 小时前
VR摩托车|沉浸式交通安全教育的新方向
科技·学习·安全·vr·虚拟现实
ZhiqianXia11 小时前
Pytorch 学习笔记(4) : torch.backends
pytorch·笔记·学习
m0_5648768411 小时前
提示词工程手册学习
人工智能·python·深度学习·学习