Qt Declarative 模塊

QDeclarativeListReference 類允許操縱 QDeclarativeListProperty 特性。 更多...

該文檔編製在 Qt 4.7 引入。

QDeclarativeComponent 封裝 QML 組件定義
QDeclarativeContext 在 QML 引擎中定義上下文
QDeclarativeEngine 用於實例化 QML 組件的環境
QDeclarativeError 封裝 QML 錯誤
QDeclarativeExpression 評估 QML 上下文中的 JavaScript
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().