C

Qt Quick Ultralite 层示例

/****************************************************************************** ** ** Copyright (C) 2020 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 import QtQuickUltralite.Layers 2.0 ImageLayer { id: root property real vx: 0 property real vy: 0 property Item container Component.onCompleted: { root.x = 1 + Math.floor(Math.random() * (container.width - root.width - 2)) root.y = 1 + Math.floor(Math.random() * (container.height - root.height - 2)) vx = Math.random() > 0.5 ? 1 : -1 vy = Math.random() > 0.5 ? 1 : -1 } onTChanged: { root.x += vx root.y += vy if (root.y <= 0 || root.y >= (container.height - root.height)) root.vy = -root.vy if (root.x <= 0 || root.x >= (container.width - root.width)) root.vx = -root.vx } property real t: 0 NumberAnimation on t { running: true loops: Animation.Infinite from: 0 to: 1 } }