Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Change a state transition on the fly

$
0
0
Hi Mark! You can define multiple Transitions and only enable the one/those you want to use, like: transitions: [    Transition { enabled: true; ... },    Transition { enabled: false; ...},    Transition { enabled: false; ...} ] I’ve created an ugly :-) example: import QtQuick 2.4 import QtQuick.Controls 1.3     Column {     Rectangle {         id: rect         width: 100; height: 100         color: "lightblue"                 MouseArea {             id: mouseArea             anchors.fill: parent         }                 states: State {             name: "grün"             when: mouseArea.pressed         }                 transitions: [             Transition {                 enabled: true                 to: "grün"                 ColorAnimation {                     target: rect                     property: "color"                     to: "lime"                     duration: 1000                 }                             },             Transition {                 enabled: false                 to: "grün"                 NumberAnimation {                     target: rect                     property: "width"                     to: 200                     duration: 1000                 }             }         ]     }     Button {         text: "Toggle transition"         onClicked: {             rect.transitions[0].enabled = !rect.transitions[0].enabled             rect.transitions[1].enabled = !rect.transitions[1].enabled         }     } } Hope that helps!

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images