C

Qt Quick Ultralite layers Example

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial

import QtQuick 2.15
import QtQuickUltralite.Layers 2.0

ItemLayer {
    id: itemLayer

    property int colorDepth: 32
    property real t: 0

    depth: (colorDepth === 32) ? ItemLayer.Bpp32 : ItemLayer.Bpp16Alpha

    NumberAnimation on t {
        running: true
        loops: Animation.Infinite
        from: 0
        to: 1
        duration: 4000
    }

    Rectangle {
        anchors.fill: parent
        color: "white"

        Rectangle {
            id: textBox
            anchors.top: parent.top
            width: parent.width
            height: parent.height * 2 / 3

            Column {
                id: textColumn
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                anchors.margins: parent.height / 16

                Text {
                    text: colorDepth + " bpp item layer"
                    font.pixelSize: 18
                    anchors.horizontalCenter: parent.horizontalCenter
                }
                Text {
                    text: "Refresh interval: " + itemLayer.refreshInterval
                    font.pixelSize: 18
                    anchors.horizontalCenter: parent.horizontalCenter
                }
            }
        }

        Image {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: textBox.bottom
            anchors.margins: parent.height / 16

            opacity: 0.8
            source: "qt-logo.png"
        }

        Rectangle {
            property int redBoxWidth: parent.height / 16
            width: redBoxWidth
            height: redBoxWidth
            anchors.bottom: parent.bottom
            x: -redBoxWidth + t * (parent.width + redBoxWidth)
            color: "red"
        }
    }
}