Hi,
On 23/04/10 2:10 AM, "ext Ivan De Marino" <[email protected]> wrote: > Hello. > This is a message purely about code "niceness". Answer only when u are done > with your daily job, and the thing in your non-mouse-holding hand is a Pina > Colada. :) > > Scenario: I have 2 .qml > - Main.qml > - common/SupaDupaComponent.qml > > In main.qml I do something like: > >> import "common" >> ... >> var component = createComponent("common/SupaDupaComponent.qml"); >> var obj = component.createObject(); >> obj.parent = aProperParent; >> ... > > This works and the world has a blue sky. > But I don't like it 100%: given that I have imported the component already (at > the first line), why do I have to search the component "by file"? > For me, something like: > >> var obj = SupaDupaComponent.createObject(); >> ... > > Should be the proper thing to have. > I know, is one line, but WHY it doesn't work if I do like that? > Isn't an included component equivalent to a "Component"? > What am I missing from the way QML handles Component's creation? Nothing. It would be nice if QML handled dynamic component creation like this, but it doesn't. The implementation reason, if you're interested, is that the JavaScript is not fully aware of all the types in scope. In future releases we might support something closer to your proposed syntax. Cheers, Aaron _______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
