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

演示

视频讲解

相关推荐
caimouse4 小时前
protoc-gen-c 支持 proto3 `optional` 关键字修改记录
c语言·学习
憧憬成为java架构高手的小白4 小时前
黑马八股--中间件学习之MQ(RabbitMQ)
学习·中间件
撩得Android一次心动6 小时前
Linux编程笔记4【个人用】
linux·笔记·学习
user-猴子6 小时前
让网页“活”过来 —— 用AI打造会自主学习的动态知识图谱
人工智能·学习·知识图谱
网络工程小王7 小时前
【HCIE-AI】10.pytorch模型迁移分析
人工智能·学习·华为·llama
马里马里奥-8 小时前
从零搭建AI Agent工具链的技术文章大纲
开发语言·qt
魔城烟雨8 小时前
从零开始学习betaflight《3-硬件接口设计规范标准》
学习·设计规范
不言鹅喻10 小时前
HarmonyOS ArkTS 实战:实现一个单词背诵与英语学习应用
学习·华为·harmonyos
正经人_x11 小时前
学习日记42
学习
一只小菜鸡..11 小时前
南京大学 操作系统 (JYY) 学习笔记:导论与历史的轮回 (OS Introduction)
笔记·学习