QQmlListProperty Class
template <typename T> class QQmlListPropertyThe QQmlListProperty class allows applications to expose list-like properties of QObject-derived classes to QML. More...
| Header: | #include <QQmlListProperty> |
| qmake: | QT += qml |
| Since: | Qt 5.0 |
This class was introduced in Qt 5.0.
Public Types
| (alias) | AppendFunction |
| (alias) | AtFunction |
| (alias) | ClearFunction |
| (alias) | CountFunction |
| (alias) | RemoveLastFunction |
| (alias) | ReplaceFunction |
Detailed Description
QML has many list properties, where more than one object value can be assigned. The use of a list property from QML looks like this:
FruitBasket {
fruit: [
Apple {},
Orange{},
Banana{}
]
}
The QQmlListProperty encapsulates a group of function pointers that represent the set of actions QML can perform on the list - adding items, retrieving items and clearing the list. In the future, additional operations may be supported. All list properties must implement the append operation, but the rest are optional.
To provide a list property, a C++ class must implement the operation callbacks, and then return an appropriate QQmlListProperty value from the property getter. List properties should have no setter. In the example above, the Q_PROPERTY() declarative will look like this:
Q_PROPERTY(QQmlListProperty<Fruit> fruit READ fruit)
QML list properties are type-safe - in this case Fruit is a QObject type that Apple, Orange and Banana all derive from.
See also Extending QML - Object and List Property Types Example.
Member Type Documentation
[alias] QQmlListProperty::AppendFunction
This is a type alias for void (*)(QQmlListProperty<T> *, T *).
Synonym for void (*)(QQmlListProperty<T> *property, T *value).
Append the value to the list property.
[alias] QQmlListProperty::AtFunction
This is a type alias for T *(*)(QQmlListProperty<T> *, int).
Synonym for T *(*)(QQmlListProperty<T> *property, int index).
Return the element at position index in the list property.
[alias] QQmlListProperty::ClearFunction
This is a type alias for void (*)(QQmlListProperty<T> *).
Synonym for void (*)(QQmlListProperty<T> *property).
Clear the list property.
[alias] QQmlListProperty::CountFunction
This is a type alias for int (*)(QQmlListProperty<T> *).
Synonym for int (*)(QQmlListProperty<T> *property).
Return the number of elements in the list property.
[alias] QQmlListProperty::RemoveLastFunction
This is a type alias for void (*)(QQmlListProperty<T> *).
Synonym for void (*)(QQmlListProperty<T> *property).
Remove the last element from the list property.
[alias] QQmlListProperty::ReplaceFunction
This is a type alias for void (*)(QQmlListProperty<T> *, int, T *).
Synonym for void (*)(QQmlListProperty<T> *property, int index, T *value).
Replace the element at position index in the list property with value.