[Development] Programmable delegate selection for QML views

Paolo Angelelli paolo.angelelli at qt.io
Tue Aug 7 11:16:09 CEST 2018


On Mon, 6 Aug 2018 15:34:00 +0200
Pierre-Yves Siret <py.siret at gmail.com> wrote:

> > - it can only nest (and thus load) QQuickItems, being a QQuickItem itself  
> Loader can wrap QObject too. This works : Instantiator { Loader { QtObject
> {} } }
> http://doc.qt.io/qt-5/qml-qtquick-loader.html#sourceComponent-prop : "Since
> QtQuick 2.0, Loader is able to load any type of object; it is not
> restricted to Item types."

True, but that example is a bit artificial.

How about nesting some other QObject * subclass that should be the delegate in a view?
And, also, loaded elements are childItems of the Loader itself, if QQuickItems.
If it's a QObject only, there's the "QObject *item" property instead.
But then views should then handle the Loader case specifically to extract the QObject.

If the view uses a delegate model, instead, at least with options 2. and 3., it would
require no special handling. If the view is supposed to have QObject delegates and
does not support (in principle) a Loader, no special handling would be required.



More information about the Development mailing list