Qlabel scrolling text



  • i have a problem in QLabel.
    my string length is larger then QLabel length so when displaying that label only that part appears.
    i have to make QLabel that show string animated just like a marquee in Html in QLabel boundary.



  • Keep in mind that moving UI elements tend to be rather distracting. Perhaps a tool tip / popup is a better solution to your problem. Anyway here is a simple marquee

    @
    import QtQuick 2.0
    import QtQuick.Controls 1.0

    Rectangle {
    width: 360
    height: 360
    Rectangle {
    id: marquee
    width: 100
    height: label.height
    color: "white"
    clip: true
    border.color: "lightgray"
    anchors.centerIn: parent
    Label {
    id: label
    x: 2
    text: "Hello I am a very long label"
    property int scrollLength: (label.implicitWidth - marquee.width) + 4
    SequentialAnimation on x {
    loops: Animation.Infinite
    NumberAnimation { to: -label.scrollLength ; duration: 2000 ; easing.type: Easing.OutSine}
    PauseAnimation { duration: 1000 }
    NumberAnimation { to: 2 ; duration: 2000 ; easing.type: Easing.OutSine}
    PauseAnimation { duration: 1000 }
    }
    }
    }
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.