[Qt-qml] Applying common behaviour to a group of elements
Alex
alexlordax+qt at gmail.com
Wed Aug 4 20:42:25 CEST 2010
Hi Alan,
Sorry for not being more clear.
I have a large number of pages, with each page containing several
elements. The "fading in" behaviour applies to the elements on a
given page.
The large number of pages is my motivation for encapsulating this
behaviour, so I don't have to re-implement it on every page.
For example, I currently have a page that has 4 elements, and I fade
them in as follows:
SequentialAnimation {
id: animations
NumberAnimation { target: e1; property: "opacity"; from: 0;
to: 1; duration: 600 }
PauseAnimation { duration: 1000 }
NumberAnimation { target: e2; property: "opacity"; from: 0;
to: 1; duration: 600 }
PauseAnimation { duration: 1000 }
NumberAnimation { target: e3; property: "opacity"; from: 0;
to: 1; duration: 600 }
PauseAnimation { duration: 1000 }
NumberAnimation { target: e4; property: "opacity"; from: 0;
to: 1; duration: 600 }
}
For this to work, I also set opacity to 0 in the definitions of e1,
e2, e3, and e4.
If I were using an imperative language, I would do something like:
Fader fader;
fader.setFadeDuration(600)
fader.setPauseDuration(1000)
fader.addElement(e1)
fader.addElement(e2)
etc
fader.start()
Is there an idiomatic way to do something similar in QML?
Cheers,
Alex
On Wed, Aug 4, 2010 at 11:24 AM, <alan.westbrook at nokia.com> wrote:
> So it's a slideshow and each element is a page, and you have hundreds of pages?
>
> Or do you have a few pages each with a bunch of elements?
>
> Or do you have hundreds of elements which pop in and out on a single page?
>
> Depending on what you mean, you could try putting your elements in a model and iterating over them setting opacity. You can also use a Behavior on opacity to enable fade in and out in the element definition.
>
> Or you can fade each page in and out, all child elements will follow the opacity of it's parent page.
>
> Alan
>
> On Aug 4, 2010, at 11:14 AM, ext Alex wrote:
>
>> Hi all,
>>
>> I am building an application that has a PowerPoint-like informational
>> component. To this end, I have a bunch of QML files that display
>> content progressively, with items fading in one at a time.
>>
>> In my current implementation, I give each object an id and set opacity
>> to 0. I then have a SequentialAnimation block that uses a
>> PropertyAnimation, individually referencing each id, to bring the
>> opacity to 1.
>>
>> This approach works but it is suboptimal (from a development point of
>> view), considering that I will have hundreds of these QML files. Is
>> there a better way to abstract/automate this behaviour?
>>
>> Thanks,
>> Alex
>> _______________________________________________
>> Qt-qml mailing list
>> Qt-qml at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-qml
>
>
More information about the Qt-qml
mailing list