Set different icons on the button depending on whether it's checked or not (since in Qt Quick we always ask for QIcon's pixmap in the "Off" state), and use Qt Quick Controls and layouts instead of positioners for proper alignments of labels and text fields. Change-Id: I1c5bd368560042ec4af8cf4bf1b9104d0257ac40 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
53 lines
1.4 KiB
QML
53 lines
1.4 KiB
QML
// Copyright (C) 2023 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
|
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
ColumnLayout {
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
ToolBar {
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
ToolButton {
|
|
id: normalButton
|
|
checkable: true
|
|
icon.name: checked ? iconNameOn.text : iconNameOff.text
|
|
}
|
|
ToolButton {
|
|
id: checkedButton
|
|
checked: true
|
|
checkable: true
|
|
icon.name: checked ? iconNameOn.text : iconNameOff.text
|
|
}
|
|
ToolButton {
|
|
id: disabledButton
|
|
enabled: false
|
|
icon.name: checked ? iconNameOn.text : iconNameOff.text
|
|
}
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
Label {
|
|
text: "Off:"
|
|
}
|
|
TextField {
|
|
id: iconNameOff
|
|
text: "mail-mark-read"
|
|
}
|
|
Label {
|
|
text: "On:"
|
|
}
|
|
TextField {
|
|
id: iconNameOn
|
|
text: "mail-mark-unread"
|
|
}
|
|
}
|
|
}
|
|
}
|