zl程序教程

您现在的位置是:首页 >  后端

当前栏目

第42篇 QML控件实例 之 Dial(表盘控件)

实例 控件 42 qml 表盘
2023-09-14 09:05:33 时间
import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3

ApplicationWindow{
    visible: true;
    width: 1280;
    height: 720;

    Label{
        id: lbl;
        text: "0";
        font.bold: true;
        font.pixelSize: 28;
        anchors.centerIn: parent;
    }

    Dial {
        id: dial
        snapMode: Dial.SnapAlways;
        stepSize: 0.1;
        onMoved: {
            lbl.text = value;
        }
    }

    Button{
        id: btnIncrease
        text: "增加"
        anchors.left: dial.right;
        anchors.leftMargin: 40;
        anchors.bottom: dial.bottom;

        onClicked: {
            dial.increase();
            lbl.text = dial.value
        }
    }

    Button{
        id: btnDecrease
        text: "减少"
        anchors.left: btnIncrease.right;
        anchors.leftMargin: 40;
        anchors.bottom: btnIncrease.bottom;

        onClicked: {
            dial.decrease();
            lbl.text = dial.value
        }
    }
}