aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/views/listview/content/ToggleButton.qml
blob: 0b196f5df6b0ca283ee4c1f1b81b280bd2d2f681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick 2.0

Rectangle {
    id: root
    property alias label: text.text
    property bool active: false
    signal toggled
    width: 149
    height: 30
    radius: 3
    color: active ? "green" : "lightgray"
    border.width: 1
    Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
    MouseArea {
        anchors.fill: parent
        onClicked: { root.active = !root.active; root.toggled() }
    }
}