ScrollText.qml
import QtQuick 2.2
import QtQuick.Window 2.2
Text {
id: scrollText;
SequentialAnimation {
id: sequentialAnimation;
running: false;
NumberAnimation {
id: numberAnimationStart;
target: scrollText;
property: "x";
duration: 10000;
easing.type: Easing.Linear;
}
NumberAnimation {
id: numberAnimationEnd;
target: scrollText;
property: "x";
duration: 0;
to: 0;
easing.type: Easing.Linear;
}
}
Timer {
id: numberAnimationTimer;
interval: 15000;
repeat:true;
triggeredOnStart: true;
running: true;
onTriggered: {
if(scrollText.x + scrollText.width > scrollText.parent.width){
numberAnimationStart.to = 0 - scrollText.width;
numberAnimationEnd.to = scrollText.x;
sequentialAnimation.running = true;
}else{
sequentialAnimation.running = false;
}
}
}
}
使用
import QtQuick 2.2
import QtQuick.Window 2.2
Rectangle {
id: videoDisplayArea;
radius: 1;
opacity: 1;
ScrollText{
id: videoDisplayAreaTitle;
x: 10;
text : "hello world qml text scroll display";
}
}
|