Package QML Type

Specifies a collection of named items. More...

Import Statement: import QtQml.Models 2.14

Attached Properties

Detailed Description

The Package type is used in conjunction with DelegateModel to enable delegates with a shared context to be provided to multiple views.

Any item within a Package may be assigned a name via the Package.name attached property.

The example below creates a Package containing two named items; list and grid. The third item in the package (the Rectangle) is parented to whichever delegate it should appear in. This allows an item to move between views.




These named items are used as the delegates by the two views who reference the special DelegateModel::parts property to select a model which provides the chosen delegate.




Note: Package is part of QtQml.Models since version 2.14 and part of QtQuick since version 2.0. Importing Package via QtQuick is deprecated since Qt 5.14.

See also Qt Quick Examples - Views, Qt Quick Demo - Photo Viewer, and Qt QML.

Attached Property Documentation

Package.name : string

This attached property holds the name of an item within a Package.