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

演示

视频讲解

相关推荐
越努力越幸运50814 分钟前
AJAX 学习第一天:axios、HTTP 基础、serialize 插件
学习·http·ajax
应用市场15 分钟前
Qt QTreeView深度解析:从原理到实战应用
开发语言·数据库·qt
im_AMBER15 分钟前
HTTP 02 会话 | 消息 | MIME类型
网络·笔记·网络协议·学习·http
lijun_xiao200927 分钟前
Apache Hadoop-学习笔记1
hadoop·学习·apache
864记忆43 分钟前
Qt Widgets 模块中的函数详解
开发语言·qt
q***72871 小时前
Golang 构建学习
开发语言·学习·golang
蓝桉~MLGT1 小时前
Python学习历程——文件
python·学习·策略模式
循环过三天1 小时前
7.5、Python-匿名函数lambda
笔记·python·学习
大大水瓶1 小时前
Nginx学习
学习·nginx·dubbo
jiushun_suanli2 小时前
FPGA(现场可编程门阵列)详解
经验分享·学习·fpga开发