///////////////////// main.qml -- call with qmlscene import QtQuick 2.0 Rectangle { id: main; width: 800; height: 480; color: "black"; Rectangle { x: 100; y: 200; width: 200; height: 200; color: "red"; MouseArea { enabled: true; anchors.fill: parent; onClicked: { if(blue_rect.opacity == 0) { blue_rect.opacity = 1.0; } else { blue_rect.opacity = 0.0; } } } } Rectangle { id: blue_rect; x: 400; y: 200; width: 200; height: 200; color: "blue"; Behavior on opacity { FadeAnimation{} } } } ////////////////////////////////// FadeAnimation.qml -- put in same folder as main.qml import QtQuick 2.0 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad; }