[Qt-qml] Component element: what is it for ?
Gregory Schlomoff
gregory.schlomoff at gmail.com
Fri Jul 23 03:33:42 CEST 2010
To add my thoughts here :
Conceptually, I think that Component are exactly like external QML
files. I think of components as a way to put in the same file the code
that you would otherwise have written in a separate file.
> Though I do not understand the difference between Loader.onLoaded() and
> Component.onComplete()
I'm am using Component.onCompleted: {} a lot, throughout my code, to
add JS code that should run at initialization. My understanding is
that every QML file is a component, and has the onCompleted event
available.
Thus you can write :
== SomeFile.qml ==
import Qt 4.7
Rectangle {
...
Component.onLoaded: {console.log("hello")}
}
Loader.onLoaded, on the other hand, is only available for loader items, I guess.
On Fri, Jul 23, 2010 at 12:50 AM, Jason H <scorp1us at yahoo.com> wrote:
> I believe that components can be instantiated but take some time to load. So
> they support a completed notification. So that once they are done loading
> you can show something atomically, and not as parts come in.
>
> Though I do not understand the difference between Loader.onLoaded() and
> Component.onComplete()
>
> I don't understand the use of Component.url. It is read-only, but this seems
> like it should be settable to resolve to remote components?
>
>
>
> ________________________________
> From: Stephen Collyer <scollyer at netspinner.co.uk>
> Cc: qt-qml at trolltech.com
> Sent: Thu, July 22, 2010 11:57:35 AM
> Subject: Re: [Qt-qml] Component element: what is it for ?
>
> On 22 July 2010 16:44, Sacha Zyto <sacha at mit.edu> wrote:
>>
>> Hi Stephen,
>>
>> My understanding is that an Item placed inside a widget will be included
>> in the UI tree at that place, and hence displayed, which you don't want,
>> say, if you've designed your component to be used as a "template" or
>> a"lens" in order to be used by a View to render Items that are inside a
>> Model.
>
>
> Right. Assuming that your explanation is correct, that makes sense.
> In that case, a Component is essentially the QML equivalent of a
> class, defining an object template but not instantiating it. I'll have to
> play
> around with this to see exactly how it works.
>
> Does an Item, conversely, both define an object template and
> instantiate it, so that an Item can be used anywhere a Component
> can be used ?
>
> --
> Stephen Collyer
>
>
> _______________________________________________
> 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