C

Qt Quick Ultralite sprite_animations Example

/****************************************************************************** ** ** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
import QtQuick 2.15 Rectangle { id: control color: "white" property bool checked: true readonly property color foregroundColor: "black" readonly property int borderWidth: 1 readonly property alias checkedText: txtChecked.text readonly property alias uncheckedText: txtUnchecked.text Row { x: control.borderWidth y: control.borderWidth spacing: control.borderWidth Rectangle { id: leftPart width: (control.width - control.borderWidth * 3) / 2 height: (control.height - control.borderWidth * 2) color: control.checked? control.color : control.foregroundColor Text { id: txtChecked anchors.centerIn: parent color: control.checked? control.foregroundColor : control.color font.pixelSize: 14 } } Rectangle { id: rightPart width: leftPart.width height: leftPart.height color: control.checked? control.foregroundColor : control.color Text { id: txtUnchecked anchors.centerIn: parent color: control.checked? control.color : control.foregroundColor font.pixelSize: 14 } } } MouseArea { anchors.fill: parent onClicked: control.checked = !control.checked } }