qml 文字滚动实现

import QtQuick 2.12
import QtQuick.Window 2.12

Window {
    visible: true
    width: 340
    height: 280
    title: qsTr("Text Scroll")

    Rectangle {
        id: scrollRect
        width: 300; height: 40;
        anchors{top: parent.top; topMargin: 50;}
        radius: 4; color: "transparent"
        Text {
            id: scrollText
            height: parent.height
            color: "red"
            font.bold: true
            font.pixelSize: 20
            verticalAlignment: Text.AlignVCenter
            text: qsTr("This reference guide describes the features of the QML language. Many of the QML types in the guide originate from the Qt QML or Qt Quick modules.")
        }

        SequentialAnimation on x {
            loops: Animation.Infinite
            PropertyAnimation {
                from: scrollRect.width
                to: -scrollText.width
                duration: 8000
            }
        }
    }

}

 

你可能感兴趣的:(qml)