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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QDeclarativeListProperty Class Reference

The QDeclarativeListProperty class allows applications to expose list-like properties to QML. More...

 #include <QDeclarativeListProperty>

This class was introduced in Qt 4.7.

Public Types

typedef AppendFunction
typedef AtFunction
typedef ClearFunction
typedef CountFunction

Public Functions

QDeclarativeListProperty ( QObject * object, QList<T *> & list )
QDeclarativeListProperty ( QObject * object, void * data, AppendFunction append, CountFunction count = 0, AtFunction at = 0, ClearFunction clear = 0 )
bool operator== ( const QDeclarativeListProperty & other ) const

Detailed Description

The QDeclarativeListProperty class allows applications to expose list-like properties to QML.

QML has many list properties, where more than one object value can be assigned. The use of a list property from QML looks like this:

 FruitBasket {
     fruit: [
         Apple {},
         Orange{},
         Banana{}
     ]
 }

The QDeclarativeListProperty encapsulates a group of function pointers that represet the set of actions QML can perform on the list - adding items, retrieving items and clearing the list. In the future, additional operations may be supported. All list properties must implement the append operation, but the rest are optional.

To provide a list property, a C++ class must implement the operation callbacks, and then return an appropriate QDeclarativeListProperty value from the property getter. List properties should have no setter. In the example above, the Q_PROPERTY() declarative will look like this:

 Q_PROPERTY(QDeclarativeListProperty<Fruit> fruit READ fruit);

QML list properties are typesafe - in this case Fruit is a QObject type that Apple, Orange and Banana all derive from.

Note: QDeclarativeListProperty can only be used for lists of QObject-derived object pointers.

See also Object and List Property Types.

Member Type Documentation

typedef QDeclarativeListProperty::AppendFunction

Synonym for void (*)(QDeclarativeListProperty<T> *property, T *value).

Append the value to the list property.

typedef QDeclarativeListProperty::AtFunction

Synonym for T *(*)(QDeclarativeListProperty<T> *property, int index).

Return the element at position index in the list property.

typedef QDeclarativeListProperty::ClearFunction

Synonym for void (*)(QDeclarativeListProperty<T> *property).

Clear the list property.

typedef QDeclarativeListProperty::CountFunction

Synonym for int (*)(QDeclarativeListProperty<T> *property).

Return the number of elements in the list property.

Member Function Documentation

QDeclarativeListProperty::QDeclarativeListProperty ( QObject * object, QList<T *> & list )

Convenience constructor for making a QDeclarativeListProperty value from an existing QList list. The list reference must remain valid for as long as object exists. object must be provided.

Generally this constructor should not be used in production code, as a writable QList violates QML's memory management rules. However, this constructor can very useful while prototyping.

QDeclarativeListProperty::QDeclarativeListProperty ( QObject * object, void * data, AppendFunction append, CountFunction count = 0, AtFunction at = 0, ClearFunction clear = 0 )

Construct a QDeclarativeListProperty from a set of operation functions. An opaque data handle may be passed which can be accessed from within the operation functions. The list property remains valid while object exists.

The append operation is compulsory and must be provided, while the count, at and clear methods are optional.

bool QDeclarativeListProperty::operator== ( const QDeclarativeListProperty & other ) const

Returns true if this QDeclarativeListProperty is equal to other, otherwise false.

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 4.8
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