Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived classes to QML. More...
#include <qqmllist.h>
Public Types | |
using | value_type = T* |
using | AppendFunction = void (*)(QQmlListProperty<T> *, T *) |
Synonym for {void (*)(QQmlListProperty<T> *property, T *value)}. | |
using | CountFunction = qsizetype (*)(QQmlListProperty<T> *) |
Synonym for {qsizetype (*)(QQmlListProperty<T> *property)}. | |
using | AtFunction = T *(*)(QQmlListProperty<T> *, qsizetype) |
Synonym for {T *(*)(QQmlListProperty<T> *property, qsizetype index)}. | |
using | ClearFunction = void (*)(QQmlListProperty<T> *) |
Synonym for {void (*)(QQmlListProperty<T> *property)}. | |
using | ReplaceFunction = void (*)(QQmlListProperty<T> *, qsizetype, T *) |
Synonym for {void (*)(QQmlListProperty<T> *property, qsizetype index, T *value)}. | |
using | RemoveLastFunction = void (*)(QQmlListProperty<T> *) |
Synonym for {void (*)(QQmlListProperty<T> *property)}. | |
Public Member Functions | |
QQmlListProperty ()=default | |
\macro QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_APPEND | |
QQmlListProperty (QObject *o, QList< T * > *list) | |
QQmlListProperty (QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r) | |
Construct a QQmlListProperty from a set of operation functions append, count, at, and clear. | |
QQmlListProperty (QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r, ReplaceFunction s, RemoveLastFunction p) | |
Construct a QQmlListProperty from a set of operation functions append, count, at, clear, replace, and \removeLast. | |
QQmlListProperty (QObject *o, void *d, CountFunction c, AtFunction a) | |
Construct a readonly QQmlListProperty from a set of operation functions count and at. | |
bool | operator== (const QQmlListProperty &o) const |
Returns true if this QQmlListProperty is equal to other, otherwise false. | |
template<typename List > | |
List | toList () |
Public Attributes | |
QObject * | object = nullptr |
void * | data = nullptr |
AppendFunction | append = nullptr |
CountFunction | count = nullptr |
AtFunction | at = nullptr |
ClearFunction | clear = nullptr |
ReplaceFunction | replace = nullptr |
RemoveLastFunction | removeLast = nullptr |
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived classes to QML.
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:
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:
QML list properties are type-safe - in this case {Fruit}
is a QObject type that {Apple}
, {Orange}
and {Banana}
all derive from.
Definition at line 24 of file qqmllist.h.
using QQmlListProperty< T >::AppendFunction = void (*)(QQmlListProperty<T> *, T *) |
Synonym for {void
(*)(QQmlListProperty<T> *property, T *value)}.
Append the value to the list property.
Definition at line 28 of file qqmllist.h.
using QQmlListProperty< T >::AtFunction = T *(*)(QQmlListProperty<T> *, qsizetype) |
Synonym for {T
*(*)(QQmlListProperty<T> *property, qsizetype index)}.
Return the element at position index in the list property.
Definition at line 30 of file qqmllist.h.
using QQmlListProperty< T >::ClearFunction = void (*)(QQmlListProperty<T> *) |
Synonym for {void
(*)(QQmlListProperty<T> *property)}.
Clear the list property.
Definition at line 31 of file qqmllist.h.
using QQmlListProperty< T >::CountFunction = qsizetype (*)(QQmlListProperty<T> *) |
Synonym for {qsizetype
(*)(QQmlListProperty<T> *property)}.
Return the number of elements in the list property.
Definition at line 29 of file qqmllist.h.
using QQmlListProperty< T >::RemoveLastFunction = void (*)(QQmlListProperty<T> *) |
Synonym for {void
(*)(QQmlListProperty<T> *property)}.
Remove the last element from the list property.
Definition at line 33 of file qqmllist.h.
using QQmlListProperty< T >::ReplaceFunction = void (*)(QQmlListProperty<T> *, qsizetype, T *) |
Synonym for {void
(*)(QQmlListProperty<T> *property, qsizetype index, T *value)}.
Replace the element at position index in the list property with value.
Definition at line 32 of file qqmllist.h.
using QQmlListProperty< T >::value_type = T* |
Definition at line 26 of file qqmllist.h.
|
default |
\macro QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_APPEND
This macro defines the behavior of the list properties of this class to Append. When assigning the property in a derived type, the values are appended to those of the base class. This is the default behavior.
\macro QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_REPLACE_IF_NOT_DEFAULT
This macro defines the behavior of the list properties of this class to ReplaceIfNotDefault. When assigning the property in a derived type, the values replace those of the base class unless it's the default property. In the case of the default property, values are appended to those of the base class.
\macro QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_REPLACE
This macro defines the behavior of the list properties of this class to Replace. When assigning the property in a derived type, the values replace those of the base class.
|
inline |
Convenience constructor for making a QQmlListProperty value from an existing QList list. The list reference must remain valid for as long as object exists. object must be provided.
Definition at line 37 of file qqmllist.h.
References QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::append, QQmlListProperty< T >::at, QQmlListProperty< T >::clear, QQmlListProperty< T >::data, QQmlListProperty< T >::object, QQmlListProperty< T >::removeLast, and QQmlListProperty< T >::replace.
Referenced by QQmlListProperty< T >::QQmlListProperty().
|
inline |
Construct a QQmlListProperty from a set of operation functions append, count, at, and clear.
An opaque data handle may be passed which can be accessed from within the operation functions. The list property remains valid while object exists.
Null pointers can be passed for any function. If any null pointers are passed in, the list will be neither designable nor alterable by the debugger. It is recommended to provide valid pointers for all functions.
Definition at line 42 of file qqmllist.h.
References QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::append, QQmlListProperty< T >::at, QQmlListProperty< T >::clear, QQmlListProperty< T >::data, QQmlListProperty< T >::object, QQmlListProperty< T >::removeLast, and QQmlListProperty< T >::replace.
Referenced by QQmlListProperty< T >::QQmlListProperty().
|
inline |
Construct a QQmlListProperty from a set of operation functions append, count, at, clear, replace, and \removeLast.
An opaque data handle may be passed which can be accessed from within the operation functions. The list property remains valid while object exists.
Null pointers can be passed for any function, causing the respective function to be synthesized using the others, if possible. QQmlListProperty can synthesize \list
Furthermore, if either of count, at, append, and clear are neither given explicitly nor synthesized, the list will be neither designable nor alterable by the debugger. It is recommended to provide enough valid pointers to avoid this situation.
Definition at line 54 of file qqmllist.h.
References QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::append, QQmlListProperty< T >::at, QQmlListProperty< T >::clear, QQmlListProperty< T >::data, QQmlListProperty< T >::object, QQmlListProperty< T >::removeLast, and QQmlListProperty< T >::replace.
Referenced by QQmlListProperty< T >::QQmlListProperty().
|
inline |
Construct a readonly QQmlListProperty from a set of operation functions count and at.
An opaque data handle may be passed which can be accessed from within the operation functions. The list property remains valid while object exists.
Definition at line 66 of file qqmllist.h.
References QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::at, QQmlListProperty< T >::data, and QQmlListProperty< T >::object.
Referenced by QQmlListProperty< T >::QQmlListProperty().
|
inline |
Returns true if this QQmlListProperty is equal to other, otherwise false.
Definition at line 70 of file qqmllist.h.
Definition at line 92 of file qqmllist.h.
References QQmlListProperty< T >::append, QQmlListProperty< T >::at, and QQmlListProperty< T >::data.
AppendFunction QQmlListProperty< T >::append = nullptr |
Definition at line 84 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::toList().
AtFunction QQmlListProperty< T >::at = nullptr |
Definition at line 86 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::toList().
ClearFunction QQmlListProperty< T >::clear = nullptr |
Definition at line 87 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::QQmlListProperty().
CountFunction QQmlListProperty< T >::count = nullptr |
Definition at line 85 of file qqmllist.h.
void* QQmlListProperty< T >::data = nullptr |
Definition at line 82 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::toList().
QObject* QQmlListProperty< T >::object = nullptr |
Definition at line 81 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::QQmlListProperty().
RemoveLastFunction QQmlListProperty< T >::removeLast = nullptr |
Definition at line 89 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::QQmlListProperty().
ReplaceFunction QQmlListProperty< T >::replace = nullptr |
Definition at line 88 of file qqmllist.h.
Referenced by QQmlListProperty< T >::QQmlListProperty(), QQmlListProperty< T >::QQmlListProperty(), and QQmlListProperty< T >::QQmlListProperty().