[Qt-qml] How to change initial state of Loader's sourceComponent?
mathias.malmqvist at nokia.com
mathias.malmqvist at nokia.com
Fri Jan 28 17:18:19 CET 2011
> It might be a bit on the messy side, but you could bind to the 'enable'
> property of the Behavior. Before you set the color, disable the
> behavior, then enable it again after.
Messy yes, but in my actual use-case the Loader is part of framework code and the
"blueRect" is a Component provided by the user of said framework, so I have no
way of knowing which Behaviors the component has.
Posted this suggestion to address the problem:
http://bugreports.qt.nokia.com/browse/QTBUG-17009
Cheers
Mathias
________________________________________
From: qt-qml-bounces+mathias.malmqvist=nokia.com at qt.nokia.com [qt-qml-bounces+mathias.malmqvist=nokia.com at qt.nokia.com] on behalf of ext Christoper Ham [christopher.ham at nokia.com]
Sent: Thursday, January 27, 2011 10:57 PM
To: qt-qml at qt.nokia.com
Subject: Re: [Qt-qml] How to change initial state of Loader's sourceComponent?
On 01/28/2011 04:27 AM, ext mathias.malmqvist at nokia.com wrote:
> Hi,
>
> Here's a little challenge for you all:
> If we assume changing the definition of the "blueRect" Component below is not allowed,
> is there any way to change the rest of the code such that the rectangle start out red instead
> of blue without the ColorAnimation being triggered?
>
> import QtQuick 1.0
> Item {
> width: 640
> height: 480
>
> Loader {
> anchors.centerIn: parent
> sourceComponent: blueRect
> onLoaded: item.color = "red" // How make rect start out red without fade from blue?
> }
>
> MouseArea {
> anchors.fill: parent
> onClicked: loader.item.color = "green"
> }
>
> Component {
> id: blueRect
> Rectangle {
> color: "blue"
> Behavior on color { ColorAnimation { duration: 1000 } }
> width: 100
> height: 100
> }
> }
> }
>
>
> Cheers
> Mathias
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
It might be a bit on the messy side, but you could bind to the 'enable'
property of the Behavior. Before you set the color, disable the
behavior, then enable it again after.
Br,
Christopher
_______________________________________________
Qt-qml mailing list
Qt-qml at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
More information about the Qt-qml
mailing list