import QtQuick 2.0
Item {
id:root width: visibleZone height: 32 // color: "red" clip:trueproperty int visibleZone:100
property int srollingTime:3000property int fontSize: 50
property int fontLetterSpace :3 property int fontWordSpace:5property string fontColor: "black"
property string hText: "" property int htextWidth: 0property int sentenceMargin:5
property string textobjectName:""property int disStyle:-1 // 0-left,1-middle,2-right
/*******************methed 1 start*************************/
Text {
id: txtFirst objectName: textobjectName font.pixelSize: fontSize font.letterSpacing: fontLetterSpace font.wordSpacing: fontWordSpace color: fontColor onTextChanged: { if(root.disStyle===0) { txtFirst.x=0 } else if(root.disStyle===1) { txtFirst.x=(root.visibleZone-txtFirst.width)*0.5 } else { txtFirst.x=root.visibleZone-txtFirst.width }htextWidth=txtFirst.width
txtSecond.text=txtFirst.text if(txtFirst.width>visibleZone) { anim.restart() txtSecond.visible=true } else { txtSecond.visible=false anim.stop() } } }Text {
id: txtSecond font.pixelSize: fontSize font.letterSpacing: fontLetterSpace font.wordSpacing: fontWordSpace color:fontColor onTextChanged: { txtSecond.x=txtFirst.width+root.sentenceMargin } } ParallelAnimation{ id:anim loops: Animation.InfiniteSequentialAnimation{
NumberAnimation{
target:txtFirst property:"x" to: -txtFirst.width-root.sentenceMargin duration: (txtFirst.width+root.sentenceMargin) / root.visibleZone * root.srollingTime }NumberAnimation{
target:txtFirst property:"x" to: txtFirst.width+root.sentenceMargin duration: 1 }NumberAnimation{
target:txtFirst property:"x" to: 0 duration: (txtFirst.width+root.sentenceMargin)/root.visibleZone * root.srollingTime }}
SequentialAnimation{NumberAnimation {
target:txtSecond property:"x" to: -txtFirst.width-root.sentenceMargin duration: (2 * txtSecond.width+2*root.sentenceMargin) / root.visibleZone * root.srollingTime }NumberAnimation{
target:txtSecond property:"x" to: txtSecond.width+root.sentenceMargin duration: 1 } }}
/*******************methed 1 ended*************************/
/*******************methed 2 start*************************/
// Timer {
// id:mytimer // interval: srollingTime/100 // running: false // repeat: true // onTriggered:{ // if(txtFirst.x<=-root.htextWidth-root.topleftX-root.sentenceMargin) txtFirst.x=root.topleftX+root.htextWidth+root.sentenceMargin // txtFirst.x-=1 // if(txtSecond.x<-root.htextWidth) txtSecond.x=root.topleftX+root.htextWidth+root.sentenceMargin*2 // txtSecond.x-=1 // } // } // Text { // id: txtFirst // objectName: textobjectName // x:root.topleftX // y:root.topleftY // font.pixelSize: fontSize // font.letterSpacing: fontLetterSpace // font.wordSpacing: fontWordSpace // color: fontColor // onWidthChanged: { // htextWidth=txtFirst.width // hText=txtFirst.text // if(htextWidth>visibleZone) // { // txtSecond.x=root.topleftX+root.htextWidth+root.sentenceMargin // txtSecond.visible=true // mytimer.restart() // } // else // { // mytimer.stop() // txtFirst.x=root.topleftX // txtSecond.visible=false // } // } // }// Text {
// id: txtSecond // x:root.topleftX+root.htextWidth+root.sentenceMargin // y:root.topleftY // font.pixelSize: fontSize // font.letterSpacing: fontLetterSpace // font.wordSpacing: fontWordSpace // color:fontColor // text: hText // }
/*******************methed 2 ended*************************/
}