Qt Declarative 模块

QDeclarativeListReference 类允许操纵 QDeclarativeListProperty 特性。 更多...

该文档编制在 Qt 4.7 引入。

QDeclarativeComponent 封装 QML 组件定义
QDeclarativeContext 在 QML 引擎中定义上下文
QDeclarativeEngine 用于实例化 QML 组件的环境
QDeclarativeError Encapsulates a QML error
QDeclarativeExpression Evaluates JavaScript in a QML context
QDeclarativeExtensionPlugin 用于自定义 QML 扩展插件的抽象基
QDeclarativeImageProvider 用于支持 QML 中像素图和线程化图像请求的接口
QDeclarativeItem The most basic of all visual items in QML
QDeclarativeListProperty Allows applications to expose list-like properties to QML
QDeclarativeNetworkAccessManagerFactory Creates QNetworkAccessManager instances for a QML engine
QDeclarativeParserStatus Updates on the QML parser state
QDeclarativeProperty Abstracts accessing properties on objects created from QML
QDeclarativePropertyMap Allows you to set key-value pairs that can be used in QML bindings
QDeclarativePropertyValueSource Interface for property value sources such as animations and bindings
QDeclarativeScriptString 封装脚本及其上下文
QDeclarativeView Widget for displaying a Qt Declarative user interface

详细描述

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:

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, 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 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().