QDeclarativeListReference

Synopsis

Functions

Detailed Description

The PySide.QtDeclarative.QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.

PySide.QtDeclarative.QDeclarativeListReference allows C++ programs to read from, and assign values to a QML list property in a simple and type safe way. A PySide.QtDeclarative.QDeclarativeListReference can be created by passing an object and property name or through a PySide.QtDeclarative.QDeclarativeProperty instance. These two are equivalant:

QDeclarativeListReference ref1(object, "children");

QDeclarativeProperty ref2(object, "children");
QDeclarativeListReference ref2 = qvariant_cast<QDeclarativeListReference>(ref2.read());

Not all QML list properties support all operations. A set of methods, PySide.QtDeclarative.QDeclarativeListReference.canAppend() , PySide.QtDeclarative.QDeclarativeListReference.canAt() , PySide.QtDeclarative.QDeclarativeListReference.canClear() and PySide.QtDeclarative.QDeclarativeListReference.canCount() allow programs to query whether an operation is supported on a given property.

QML list properties are typesafe. Only PySide.QtCore.QObject ‘s that derive from the correct base class can be assigned to the list. The PySide.QtDeclarative.QDeclarativeListReference.listElementType() method can be used to query the PySide.QtCore.QMetaObject of the PySide.QtCore.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 PySide.QtDeclarative.QDeclarativeListReference.count() method before calling PySide.QtDeclarative.QDeclarativeListReference.at() .

class PySide.QtDeclarative.QDeclarativeListReference
class PySide.QtDeclarative.QDeclarativeListReference(arg__1, property[, arg__3=None])
class PySide.QtDeclarative.QDeclarativeListReference(arg__1)
Parameters:

Constructs an invalid instance.

Constructs a PySide.QtDeclarative.QDeclarativeListReference for object ‘s property . If property is not a list property, an invalid PySide.QtDeclarative.QDeclarativeListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold PySide.QtDeclarative.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.

PySide.QtDeclarative.QDeclarativeListReference.append(arg__1)
Parameters:arg__1PySide.QtCore.QObject
Return type:PySide.QtCore.bool

Appends object to the list. Returns true if the operation succeeded, otherwise false.

PySide.QtDeclarative.QDeclarativeListReference.at(arg__1)
Parameters:arg__1PySide.QtCore.int
Return type:PySide.QtCore.QObject

Returns the list element at index , or 0 if the operation failed.

PySide.QtDeclarative.QDeclarativeListReference.canAppend()
Return type:PySide.QtCore.bool

Returns true if the list property can be appended to, otherwise false. Returns false if the reference is invalid.

PySide.QtDeclarative.QDeclarativeListReference.canAt()
Return type:PySide.QtCore.bool

Returns true if the list property can queried by index, otherwise false. Returns false if the reference is invalid.

PySide.QtDeclarative.QDeclarativeListReference.canClear()
Return type:PySide.QtCore.bool

Returns true if the list property can be cleared, otherwise false. Returns false if the reference is invalid.

PySide.QtDeclarative.QDeclarativeListReference.canCount()
Return type:PySide.QtCore.bool

Returns true if the list property can be queried for its element count, otherwise false. Returns false if the reference is invalid.

PySide.QtDeclarative.QDeclarativeListReference.clear()
Return type:PySide.QtCore.bool

Clears the list. Returns true if the operation succeeded, otherwise false.

PySide.QtDeclarative.QDeclarativeListReference.count()
Return type:PySide.QtCore.int

Returns the number of objects in the list, or 0 if the operation failed.

PySide.QtDeclarative.QDeclarativeListReference.isValid()
Return type:PySide.QtCore.bool

Returns true if the instance refers to a valid list property, otherwise false.

PySide.QtDeclarative.QDeclarativeListReference.listElementType()
Return type:PySide.QtCore.QMetaObject

Returns the PySide.QtCore.QMetaObject for the elements stored in the list property. Returns 0 if the reference is invalid.

The PySide.QtCore.QMetaObject can be used ahead of time to determine whether a given instance can be added to a list.

PySide.QtDeclarative.QDeclarativeListReference.object()
Return type:PySide.QtCore.QObject

Returns the list property’s object. Returns 0 if the reference is invalid.