内容表

上一话题

QQmlIncubator

下一话题

QQmlNetworkAccessManagerFactory

QQmlListReference

QQmlListReference class allows the manipulation of QQmlListProperty 特性。 更多

Inheritance diagram of PySide2.QtQml.QQmlListReference

概要

函数

详细描述

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

QQmlListReference ref1(object, "children");
QQmlProperty ref2(object, "children");
QQmlListReference ref2 = qvariant_cast<QQmlListReference>(ref2.read());
											

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 type-safe. 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 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() .

class QQmlListReference

QQmlListReference(arg__1, property[, arg__3=None])

QQmlListReference(arg__1)

param property

str

param arg__1

QObject

param arg__3

QQmlEngine

Constructs an invalid instance.

构造 QQmlListReference for object ‘s 特性 。若 特性 is not a list property, an invalid QQmlListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QQmlListReference instances even after object 被删除。

传递 engine is required to access some QML created list properties. If in doubt, and an engine is available, pass it.

PySide2.QtQml.QQmlListReference. append ( arg__1 )
参数

arg__1 QObject

返回类型

bool

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

另请参阅

canAppend()

PySide2.QtQml.QQmlListReference. at ( arg__1 )
参数

arg__1 int

返回类型

QObject

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

另请参阅

canAt()

PySide2.QtQml.QQmlListReference. canAppend ( )
返回类型

bool

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

另请参阅

append()

PySide2.QtQml.QQmlListReference. canAt ( )
返回类型

bool

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

另请参阅

at()

PySide2.QtQml.QQmlListReference. canClear ( )
返回类型

bool

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

另请参阅

clear()

PySide2.QtQml.QQmlListReference. canCount ( )
返回类型

bool

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

另请参阅

count()

PySide2.QtQml.QQmlListReference. canRemoveLast ( )
返回类型

bool

Returns true if the last item can be removed from the list property, otherwise false. Returns false if the reference is invalid.

另请参阅

removeLast()

PySide2.QtQml.QQmlListReference. canReplace ( )
返回类型

bool

Returns true if items in the list property can be replaced, otherwise false. Returns false if the reference is invalid.

另请参阅

replace()

PySide2.QtQml.QQmlListReference. clear ( )
返回类型

bool

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

另请参阅

canClear()

PySide2.QtQml.QQmlListReference. count ( )
返回类型

int

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

PySide2.QtQml.QQmlListReference. isManipulable ( )
返回类型

bool

返回 True 若 at() , count() , append() , and either clear() or removeLast() are implemented, so you can manipulate the list.

Mind that replace() and removeLast() can be emulated by stashing all items and rebuilding the list using clear() and append() . Therefore, they are not required for the list to be manipulable. Furthermore, clear() can be emulated using removeLast() .

PySide2.QtQml.QQmlListReference. isReadable ( )
返回类型

bool

返回 True 若 at() and count() are implemented, so you can access the elements.

PySide2.QtQml.QQmlListReference. isValid ( )
返回类型

bool

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

PySide2.QtQml.QQmlListReference. listElementType ( )
返回类型

QMetaObject

返回 QMetaObject for the elements stored in the list property, or None if the reference is invalid.

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

PySide2.QtQml.QQmlListReference. object ( )
返回类型

QObject

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

PySide2.QtQml.QQmlListReference. removeLast ( )
返回类型

bool

Removes the last item in the list. Returns true if the operation succeeded, otherwise false.

另请参阅

canRemoveLast()

PySide2.QtQml.QQmlListReference. replace ( arg__1 , arg__2 )
参数
  • arg__1 int

  • arg__2 QObject

返回类型

bool

Replaces the item at index in the list with object . Returns true if the operation succeeded, otherwise false.

另请参阅

canReplace()