Qt 4.8
|
The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties. More...
#include <qdeclarativelist.h>
Public Functions | |
bool | append (QObject *) const |
Appends object to the list. More... | |
QObject * | at (int) const |
Returns the list element at index, or 0 if the operation failed. More... | |
bool | canAppend () const |
Returns true if the list property can be appended to, otherwise false. More... | |
bool | canAt () const |
Returns true if the list property can queried by index, otherwise false. More... | |
bool | canClear () const |
Returns true if the list property can be cleared, otherwise false. More... | |
bool | canCount () const |
Returns true if the list property can be queried for its element count, otherwise false. More... | |
bool | clear () const |
Clears the list. More... | |
int | count () const |
Returns the number of objects in the list, or 0 if the operation failed. More... | |
bool | isValid () const |
Returns true if the instance refers to a valid list property, otherwise false. More... | |
const QMetaObject * | listElementType () const |
Returns the QMetaObject for the elements stored in the list property. More... | |
QObject * | object () const |
Returns the list property's object. More... | |
QDeclarativeListReference & | operator= (const QDeclarativeListReference &) |
QDeclarativeListReference () | |
Constructs an invalid instance. More... | |
QDeclarativeListReference (QObject *, const char *property, QDeclarativeEngine *=0) | |
Constructs a QDeclarativeListReference for object's property. More... | |
QDeclarativeListReference (const QDeclarativeListReference &) | |
~QDeclarativeListReference () | |
Properties | |
QDeclarativeListReferencePrivate * | d |
Friends | |
class | QDeclarativeListReferencePrivate |
The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.
QDeclarativeListReference allows C++ programs to read from, and assign values to a QML list property in a simple and type safe way. A QDeclarativeListReference can be created by passing an object and property name or through a QDeclarativeProperty instance. These two are equivalant:
Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and canCount() allow programs to query whether an operation is supported on a given property.
QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported. Attempting to add objects of the incorrect type to a list property will fail.
Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure that it does not request an out of range element using the count() method before calling at().
Definition at line 117 of file qdeclarativelist.h.
QDeclarativeListReference::QDeclarativeListReference | ( | ) |
QDeclarativeListReference::QDeclarativeListReference | ( | QObject * | object, |
const char * | property, | ||
QDeclarativeEngine * | engine = 0 |
||
) |
Constructs a QDeclarativeListReference for object's property.
If property is not a list property, an invalid QDeclarativeListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QDeclarativeListReference instances even after object is deleted.
Passing engine is required to access some QML created list properties. If in doubt, and an engine is available, pass it.
Definition at line 136 of file qdeclarativelist.cpp.
QDeclarativeListReference::QDeclarativeListReference | ( | const QDeclarativeListReference & | o | ) |
Definition at line 162 of file qdeclarativelist.cpp.
QDeclarativeListReference::~QDeclarativeListReference | ( | ) |
Definition at line 178 of file qdeclarativelist.cpp.
bool QDeclarativeListReference::append | ( | QObject * | object | ) | const |
Appends object to the list.
Returns true if the operation succeeded, otherwise false.
Definition at line 262 of file qdeclarativelist.cpp.
QObject * QDeclarativeListReference::at | ( | int | index | ) | const |
Returns the list element at index, or 0 if the operation failed.
Definition at line 279 of file qdeclarativelist.cpp.
bool QDeclarativeListReference::canAppend | ( | ) | const |
Returns true if the list property can be appended to, otherwise false.
Returns false if the reference is invalid.
Definition at line 219 of file qdeclarativelist.cpp.
Referenced by append().
bool QDeclarativeListReference::canAt | ( | ) | const |
Returns true if the list property can queried by index, otherwise false.
Returns false if the reference is invalid.
Definition at line 230 of file qdeclarativelist.cpp.
Referenced by at().
bool QDeclarativeListReference::canClear | ( | ) | const |
Returns true if the list property can be cleared, otherwise false.
Returns false if the reference is invalid.
Definition at line 241 of file qdeclarativelist.cpp.
Referenced by clear().
bool QDeclarativeListReference::canCount | ( | ) | const |
Returns true if the list property can be queried for its element count, otherwise false.
Returns false if the reference is invalid.
Definition at line 252 of file qdeclarativelist.cpp.
Referenced by count().
bool QDeclarativeListReference::clear | ( | ) | const |
Clears the list.
Returns true if the operation succeeded, otherwise false.
Definition at line 291 of file qdeclarativelist.cpp.
int QDeclarativeListReference::count | ( | ) | const |
Returns the number of objects in the list, or 0 if the operation failed.
Definition at line 303 of file qdeclarativelist.cpp.
bool QDeclarativeListReference::isValid | ( | ) | const |
Returns true if the instance refers to a valid list property, otherwise false.
Definition at line 186 of file qdeclarativelist.cpp.
Referenced by canAppend(), canAt(), canClear(), canCount(), listElementType(), and object().
const QMetaObject * QDeclarativeListReference::listElementType | ( | ) | const |
Returns the QMetaObject for the elements stored in the list property.
Returns 0 if the reference is invalid.
The QMetaObject can be used ahead of time to determine whether a given instance can be added to a list.
Definition at line 207 of file qdeclarativelist.cpp.
QObject * QDeclarativeListReference::object | ( | ) | const |
Returns the list property's object.
Returns 0 if the reference is invalid.
Definition at line 194 of file qdeclarativelist.cpp.
Referenced by QDeclarativeListReference().
QDeclarativeListReference & QDeclarativeListReference::operator= | ( | const QDeclarativeListReference & | o | ) |
Definition at line 169 of file qdeclarativelist.cpp.
|
friend |
Definition at line 142 of file qdeclarativelist.h.
Referenced by QDeclarativeListReference().
|
private |
Definition at line 143 of file qdeclarativelist.h.
Referenced by append(), at(), canAppend(), canAt(), canClear(), canCount(), clear(), count(), QDeclarativeListReferencePrivate::init(), isValid(), listElementType(), object(), operator=(), QDeclarativeListReference(), and ~QDeclarativeListReference().