sl@25: import QtQuick 2.2 sl@28: import QtQuick.Controls 1.2 sl@25: sl@25: Item { sl@28: id:item sl@25: height: scrollingText.height sl@25: clip: true sl@28: antialiasing: false sl@26: property int pixelsPerSeconds:25 sl@25: property alias text: scrollingText.text sl@26: property alias separator: separatorText.text sl@26: sl@28: Label { sl@25: id:scrollingText sl@28: antialiasing: item.antialiasing sl@25: } sl@25: sl@28: Label { sl@26: id:separatorText sl@26: text:" || " sl@26: x:scrollingText.x+scrollingText.width sl@28: antialiasing: item.antialiasing sl@26: } sl@26: sl@28: Label { sl@26: id:followingText sl@26: text:scrollingText.text sl@26: x:scrollingText.x+scrollingText.width+separatorText.width sl@28: antialiasing: item.antialiasing sl@26: } sl@26: sl@26: ParallelAnimation { sl@26: id: animation sl@26: loops: Animation.Infinite; sl@26: //Reset to zero and restart onStopped so that we keep looping sl@26: //onStopped: {scrollingText.x=0;running=true;} sl@26: sl@27: NumberAnimation { sl@26: target: scrollingText; sl@27: properties: "x" sl@26: //from: 0; sl@26: to: -scrollingText.width-separatorText.width; sl@26: duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds sl@26: } sl@26: sl@27: NumberAnimation { sl@26: target: separatorText; sl@27: properties: "x" sl@26: from: separatorText.x; sl@26: to: separatorText.x-scrollingText.width-separatorText.width; sl@26: duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds sl@26: } sl@26: sl@27: NumberAnimation { sl@26: target: followingText; sl@27: properties: "x" sl@26: from: followingText.x; sl@26: to: followingText.x-scrollingText.width-separatorText.width; sl@26: duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds sl@26: } sl@26: sl@26: } sl@26: sl@27: //Click to start sl@25: MouseArea { sl@25: id:mouseArea sl@25: anchors.fill: parent sl@25: onClicked: { sl@26: animation.running=true; sl@25: } sl@26: sl@25: } sl@25: }