Dynamic attached Behavior


  • Qt Champions 2016

    Hi,

    Is it possible to attach a Behavior object to a QML item dynamically?

    For example, take out the "Behavior on width" from the code, and assign another "Behavior" after construction by code?

    import QtQuick 2.0
    
    Rectangle {
        id: rect
        width: 100; height: 100
        color: "red"
    
        Behavior on width {
            NumberAnimation { duration: 1000 }
        }
    
        MouseArea {
            anchors.fill: parent
            onClicked: rect.width = 50
        }
    }
    

Log in to reply
 

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