QDeclarativeListReference

概要

函数

详细描述

PySide.QtDeclarative.QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty 特性。

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 )
参数:

Constructs an invalid instance.

构造 PySide.QtDeclarative.QDeclarativeListReference for object ‘s property 。若 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.

传递 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 )
参数: arg__1 PySide.QtCore.QObject
返回类型: PySide.QtCore.bool

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

PySide.QtDeclarative.QDeclarativeListReference. at ( arg__1 )
参数: arg__1 PySide.QtCore.int
返回类型: PySide.QtCore.QObject

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

PySide.QtDeclarative.QDeclarativeListReference. canAppend ( )
返回类型: 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 ( )
返回类型: 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 ( )
返回类型: 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 ( )
返回类型: 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 ( )
返回类型: PySide.QtCore.bool

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

PySide.QtDeclarative.QDeclarativeListReference. count ( )
返回类型: PySide.QtCore.int

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

PySide.QtDeclarative.QDeclarativeListReference. isValid ( )
返回类型: PySide.QtCore.bool

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

PySide.QtDeclarative.QDeclarativeListReference. listElementType ( )
返回类型: PySide.QtCore.QMetaObject

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

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 ( )
返回类型: PySide.QtCore.QObject

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