aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/canvas/LabeledSlider.qml
blob: 5cab697b18d301e621ac25a3fed4e4aff9153d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls

Item {
    id: labeledSlider
    property alias name: label.text
    implicitHeight: Math.max(label.implicitHeight, quickControlsSlider.implicitHeight)
    property real min: 0.0
    property real max: 1.0
    property real init: 0.0
    readonly property alias value: quickControlsSlider.value

    Label {
        id: label
        anchors.left: parent.left
        anchors.leftMargin: 10
        anchors.verticalCenter: parent.verticalCenter
        color: "#333"
        font: Qt.font({pointSize: 13})
    }

    Slider {
        id: quickControlsSlider
        anchors.verticalCenter: parent.verticalCenter
        anchors.right: parent.right
        anchors.rightMargin: 10
        anchors.left: label.right
        anchors.leftMargin: 20
        from: labeledSlider.min
        to: labeledSlider.max
        width: labeledSlider.width - label.implicitWidth - (label.anchors.leftMargin + anchors.rightMargin + anchors.leftMargin)

        Component.onCompleted: ()=> value = labeledSlider.init;
    }
}