[Qt-qml] Applying common behaviour to a group of elements

michael.brasser at nokia.com michael.brasser at nokia.com
Thu Aug 5 02:14:35 CEST 2010


On 05/08/2010, at 10:02 AM, ext Alex wrote:

> C++ method:
> 
> void Sequencer::addItem(QDeclarativeItem *item)
> {
>    item->setOpacity(1);
> }
> 
> 
> Representative QML, not verbatim:
> 
>    Behavior on opacity {
>        NumberAnimation { to: 1; duration: 1000 }
>    }
> 
> This correctly changes the opacity but fails to run the NumberAnimation.

Behavior relies on being able to intercept changes to properties. Calling setOpacity directly in C++ bypasses the property system and thus Behaviors as well. If you changed the code to item->setProperty("opacity", 1); the Behavior should be correctly triggered.

Regards,
Michael



More information about the Qt-qml mailing list