[Development] QtQml Loader API

Alan Alpert 416365416c at gmail.com
Tue Dec 11 04:32:42 CET 2012


Finally Qt 5 brings better QtQml and QtQuick separation! Better, not
perfect. The main things I've heard are missing is dynamic
instantiation of non-Items. What I propose is a new element for the
QtQml module which provides that functionality. Note that while some
people have suggested that Repeater and Loader could just accept
non-Item delegates, they both provide visual item related
functionality. For example, Repeater assigns items to the
Item::children property and Loader has visual sizing behavior. We
can't just disable that functionality if the delegate is non-visual,
because (aside from being a terrible API) we want the functionality in
the QtQml import. So lets start thinking about the potential API for
this functionality. Here's my first thoughts.

Prototype API of the Instantiator element:
QtObject {
    property bool active: true
property
    property model model: 1
    property Component delegate //Note Component is in the QtQml module
    property QtObject object //Convenience for objects[0]
    property list<QtObject> objects
}

The big question about this API is whether it's better served with two
elements. I'm thinking it could be done with just a single element,
but maybe it's worth duplicating it to have a Loader-like one (with
just object) and a Repeater-like one (with just objects). Note that
Repeater and Loader have some GUI functionality that is different for
groups versus single objects - Repeater visually reparents all
children (only really useful for groups) and Loader controls the size
of its one object (only really feasible for one). Is it worth making
two separate types?

--
Alan Alpert



More information about the Development mailing list