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

演示

视频讲解

相关推荐
一楼的猫1 分钟前
AI辅助长篇小说创作的“记忆崩坏“问题与结构管理策略
人工智能·学习·机器学习·chatgpt·ai作画·ai写作
ALINX技术博客6 分钟前
【黑金云课堂】FPGA技术教程Linux开发:NVMe/Qt/OpenCV人脸检测
linux·qt·fpga开发
We Just Keep growing11 分钟前
【MySQL运维篇】——日志、主从复制、分库分表、读写分离
java·运维·数据库·windows·学习·mysql
Jun6261 小时前
QT(4)-EXCEL操作
开发语言·qt·excel
锦鲤52141 小时前
Coze智能体学习
学习
-To be number.wan1 小时前
计算机组成原理 | Cache和主存的映射方式
学习·缓存·计算机组成原理
数智工坊2 小时前
周志华《Machine Learning》学习笔记--第八章--集成学习
笔记·学习·机器学习
星雨流星天的笔记本2 小时前
CATTI三笔综合-改错题总结(1-10)
学习
星幻元宇VR2 小时前
消防安全警示教育展厅设备【消防标识互动体验系统】
科技·学习·安全
我有满天星辰2 小时前
【Dart 语言学习教程 】 第二章:面向对象编程
学习·flutter·dart