Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QQmlListReference Class

The QQmlListReference class allows the manipulation of QQmlListProperty properties. More...

 #include <QQmlListReference>

This class was introduced in Qt 5.0.

Public Functions

QQmlListReference()
QQmlListReference(QObject * object, const char * property, QQmlEngine * engine = 0)
bool append(QObject * object) const
QObject * at(int index) const
bool canAppend() const
bool canAt() const
bool canClear() const
bool canCount() const
bool clear() const
int count() const
bool isValid() const
const QMetaObject * listElementType() const
QObject * object() const

Detailed Description

The QQmlListReference class allows the manipulation of QQmlListProperty properties.

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 equivalant:

 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 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 of the 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().

The QtQuick 1 version of this class is named QDeclarativeListReference.

Member Function Documentation

QQmlListReference::QQmlListReference()

Constructs an invalid instance.

QQmlListReference::QQmlListReference(QObject * object, const char * property, QQmlEngine * engine = 0)

Constructs a QQmlListReference for object's property. If property 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 is deleted.

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

bool QQmlListReference::append(QObject * object) const

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

See also canAppend().

QObject * QQmlListReference::at(int index) const

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

See also canAt().

bool QQmlListReference::canAppend() const

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

See also append().

bool QQmlListReference::canAt() const

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

See also at().

bool QQmlListReference::canClear() const

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

See also clear().

bool QQmlListReference::canCount() const

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

See also count().

bool QQmlListReference::clear() const

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

See also canClear().

int QQmlListReference::count() const

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

bool QQmlListReference::isValid() const

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

const QMetaObject * QQmlListReference::listElementType() const

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

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

QObject * QQmlListReference::object() const

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

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web