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

演示

视频讲解

相关推荐
shenghaide_jiahu21 小时前
数学分析简明教程——2.2(未完)
学习
Brookty1 天前
【算法】位运算| & ^ ~ -n n-1
学习·算法·leetcode·位运算
shenghaide_jiahu1 天前
数学分析简明教程——1.4(未完)
学习
tritone1 天前
在优豆云的免费云服务器上开启MongoDB学习之旅
服务器·学习·mongodb
俊俊谢1 天前
【第一章】金融数据的获取——金融量化学习入门笔记
笔记·python·学习·金融·量化·akshare
Yupureki1 天前
从零开始的C++学习生活 20:数据结构与STL复习课(4.4w字全解析)
c语言·数据结构·c++·学习·visual studio·1024程序员节
大白的编程日记.1 天前
计算机网络学习笔记】初始网络之网络发展和OSI七层模型
笔记·学习·计算机网络
春蕾夏荷_7282977251 天前
qcustomplot 显示坐标轴
qt·qcustomplot·坐标轴
郝学胜-神的一滴1 天前
Qt删除布局与布局切换技术详解
开发语言·数据库·c++·qt·程序人生·系统架构
~kiss~1 天前
spark-SQL学习
sql·学习·spark