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

演示

视频讲解

相关推荐
架构文摘JGWZ2 分钟前
Kafka 消息丢失如何处理?
学习
阳光开朗_大男孩儿3 小时前
DBUS属性原理
linux·服务器·前端·数据库·qt
linly12193 小时前
python学习笔记目录
笔记·学习
LvManBa4 小时前
Vue学习记录之四(computed的用法)
前端·vue.js·学习
Alphapeople4 小时前
Qt Modbus
开发语言·qt
竹林海中敲代码4 小时前
Qt Creator 集成开发环境 常见问题
qt·qt工具常见问题
Li小李同学Li4 小时前
git学习【持续更新中。。。】
git·学习·elasticsearch
·云扬·5 小时前
Shiro框架
笔记·学习·java-ee
优思学院6 小时前
优思学院|如何从零开始自己学习六西格玛?
大数据·运维·服务器·学习·六西格玛黑带·cssbb
LN花开富贵6 小时前
stm32g431rbt6芯片中VREF+是什么?在电路中怎么设计?
笔记·stm32·单片机·嵌入式硬件·学习