C

Qt Quick Ultralite Motorcycle Cluster Demo

/****************************************************************************** ** ** 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.Extras 2.0 Column { id: root property int rpm: 10000 property int rpmAnimationTime: 1000 Behavior on rpm { NumberAnimation { duration: rpmAnimationTime } } readonly property int changeOpacityAnimationDuration: 250 spacing: -43 readonly property ListModel tachoElements: ListModel { id: tachoImagesModel ListElement { xPos: 95 img: "images/tacho/1.png"; } ListElement { xPos: 66 img: "images/tacho/2.png"; } ListElement { xPos: 37 img: "images/tacho/3.png"; } ListElement { xPos: 13 img: "images/tacho/4.png"; } ListElement { xPos: 2 img: "images/tacho/5.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 0 img: "images/tacho/6.png"; } ListElement { xPos: 2 img: "images/tacho/5.png"; } ListElement { xPos: 13 img: "images/tacho/4.png"; } ListElement { xPos: 37 img: "images/tacho/3.png"; } ListElement { xPos: 66 img: "images/tacho/2.png"; } ListElement { xPos: 95 img: "images/tacho/1.png"; } } Repeater { id: tachoImages model: tachoElements ColorizedImage { id: img source: model.img x: model.xPos opacity: (tachoElements.count - index) * 1000 <= root.rpm ? 1 : 0 color: index<=2 ? Style.pureRed : Style.white transform: Scale { yScale: index<5 ? -1 : 1 origin.x: img.implicitWidth / 2 origin.y: img.implicitHeight / 2 } Behavior on opacity { NumberAnimation{ duration: changeOpacityAnimationDuration } } } } }