Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dynamic attached Behavior
Forum Updated to NodeBB v4.3 + New Features

Dynamic attached Behavior

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 303 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benlau
    Qt Champions 2016
    wrote on 27 Feb 2016, 13:44 last edited by
    #1

    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
        }
    }
    
    1 Reply Last reply
    0

    1/1

    27 Feb 2016, 13:44

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved