qt6-bb10/qtdeclarative/examples/quick/views/listview/content/ToggleButton.qml

22 lines
533 B
QML

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
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() }
}
}