Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skills/optional/qml/examples/01-hello/hello.qml

Raw
// 01-hello/hello.qml
// Smallest interactive QML: a rectangle that changes color on click.
// Pure standard-library QML. Run with: qml6 hello.qml

import QtQuick
import QtQuick.Window

Window {
    width: 300
    height: 200
    visible: true
    title: "QML 01: Hello"

    Rectangle {
        id: box
        anchors.fill: parent
        anchors.margins: 20
        radius: 12
        color: box.count % 2 ? "steelblue" : "tomato"

        // count is a property the binding to `color` will react to.
        property int count: 0
        Text {
            anchors.centerIn: parent
            text: "clicked " + box.count + (box.count === 1 ? " time" : " times")
            color: "white"
            font.pixelSize: 18
        }
        TapHandler {
            id: tap
            onTapped: box.count++
        }
    }
}