Qt 4.8
Public Types | Public Functions | Public Variables | Static Private Functions | List of all members
QDeclarativeListProperty< T > Class Template Reference

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

#include <qdeclarativelist.h>

Public Types

typedef void(* AppendFunction) (QDeclarativeListProperty< T > *, T *)
 Synonym for {void (*)(QDeclarativeListProperty<T> *property, T *value)}. More...
 
typedef void(* AppendFunction) (QDeclarativeListProperty< T > *, T *)
 
typedef T *(* AtFunction) (QDeclarativeListProperty< T > *, int)
 Synonym for {T *(*)(QDeclarativeListProperty<T> *property, int index)}. More...
 
typedef T *(* AtFunction) (QDeclarativeListProperty< T > *, int)
 
typedef void(* ClearFunction) (QDeclarativeListProperty< T > *)
 Synonym for {void (*)(QDeclarativeListProperty<T> *property)}. More...
 
typedef void(* ClearFunction) (QDeclarativeListProperty< T > *)
 
typedef int(* CountFunction) (QDeclarativeListProperty< T > *)
 Synonym for {int (*)(QDeclarativeListProperty<T> *property)}. More...
 
typedef int(* CountFunction) (QDeclarativeListProperty< T > *)
 

Public Functions

bool operator== (const QDeclarativeListProperty &o) const
 Returns true if this QDeclarativeListProperty is equal to other, otherwise false. More...
 
bool operator== (const QDeclarativeListProperty &o) const
 
 QDeclarativeListProperty ()
 
 QDeclarativeListProperty (QObject *o, QList< T *> &list)
 Convenience constructor for making a QDeclarativeListProperty value from an existing QList list. More...
 
 QDeclarativeListProperty (QObject *o, void *d, AppendFunction a, CountFunction c=0, AtFunction t=0, ClearFunction r=0)
 Construct a QDeclarativeListProperty from a set of operation functions. More...
 
 QDeclarativeListProperty ()
 
 QDeclarativeListProperty (QObject *o, QList< T *> &list)
 
 QDeclarativeListProperty (QObject *o, void *d, AppendFunction a, CountFunction c=0, AtFunction t=0, ClearFunction r=0)
 

Public Variables

AppendFunction append
 
AtFunction at
 
ClearFunction clear
 
CountFunction count
 
void * data
 
void * dummy1
 
void * dummy2
 
QObjectobject
 

Static Private Functions

static void qlist_append (QDeclarativeListProperty *p, T *v)
 
static void qlist_append (QDeclarativeListProperty *p, T *v)
 
static T * qlist_at (QDeclarativeListProperty *p, int idx)
 
static T * qlist_at (QDeclarativeListProperty *p, int idx)
 
static void qlist_clear (QDeclarativeListProperty *p)
 
static void qlist_clear (QDeclarativeListProperty *p)
 
static int qlist_count (QDeclarativeListProperty *p)
 
static int qlist_count (QDeclarativeListProperty *p)
 

Detailed Description

template<typename T>
class QDeclarativeListProperty< T >

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

Since
4.7

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 ) declarative will;;

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}

Definition at line 61 of file qdeclarativelist.h.

Typedefs

◆ AppendFunction [1/2]

template<typename T>
QDeclarativeListProperty< T >::AppendFunction

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

Append the value to the list property.

Definition at line 63 of file qdeclarativelist.h.

◆ AppendFunction [2/2]

template<typename T>
typedef void(* QDeclarativeListProperty< T >::AppendFunction) (QDeclarativeListProperty< T > *, T *)

Definition at line 79 of file qgraphicsitem_p.h.

◆ AtFunction [1/2]

template<typename T>
QDeclarativeListProperty< T >::AtFunction

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

Return the element at position index in the list property.

Definition at line 65 of file qdeclarativelist.h.

◆ AtFunction [2/2]

template<typename T>
typedef T*(* QDeclarativeListProperty< T >::AtFunction) (QDeclarativeListProperty< T > *, int)

Definition at line 81 of file qgraphicsitem_p.h.

◆ ClearFunction [1/2]

template<typename T>
QDeclarativeListProperty< T >::ClearFunction

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

Clear the list property.

Definition at line 66 of file qdeclarativelist.h.

◆ ClearFunction [2/2]

template<typename T>
typedef void(* QDeclarativeListProperty< T >::ClearFunction) (QDeclarativeListProperty< T > *)

Definition at line 82 of file qgraphicsitem_p.h.

◆ CountFunction [1/2]

template<typename T>
QDeclarativeListProperty< T >::CountFunction

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

Return the number of elements in the list property.

Definition at line 64 of file qdeclarativelist.h.

◆ CountFunction [2/2]

template<typename T>
typedef int(* QDeclarativeListProperty< T >::CountFunction) (QDeclarativeListProperty< T > *)

Definition at line 80 of file qgraphicsitem_p.h.

Constructors and Destructors

◆ QDeclarativeListProperty() [1/6]

template<typename T>
QDeclarativeListProperty< T >::QDeclarativeListProperty ( )
inline
Warning
This function is not part of the public interface.

Definition at line 68 of file qdeclarativelist.h.

◆ QDeclarativeListProperty() [2/6]

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

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.

Definition at line 70 of file qdeclarativelist.h.

72  clear(qlist_clear), dummy1(0), dummy2(0) {}
static void qlist_append(QDeclarativeListProperty *p, T *v)
static int qlist_count(QDeclarativeListProperty *p)
static void qlist_clear(QDeclarativeListProperty *p)
static T * qlist_at(QDeclarativeListProperty *p, int idx)

◆ QDeclarativeListProperty() [3/6]

template<typename T>
QDeclarativeListProperty< T >::QDeclarativeListProperty ( QObject object,
void *  data,
AppendFunction  append,
CountFunction  count = 0,
AtFunction  at = 0,
ClearFunction  clear = 0 
)
inline

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.

Definition at line 73 of file qdeclarativelist.h.

75  : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ QDeclarativeListProperty() [4/6]

template<typename T>
QDeclarativeListProperty< T >::QDeclarativeListProperty ( )
inline

◆ QDeclarativeListProperty() [5/6]

template<typename T>
QDeclarativeListProperty< T >::QDeclarativeListProperty ( QObject o,
QList< T *> &  list 
)
inline

Definition at line 86 of file qgraphicsitem_p.h.

88  clear(qlist_clear), dummy1(0), dummy2(0) {}
static void qlist_append(QDeclarativeListProperty *p, T *v)
static int qlist_count(QDeclarativeListProperty *p)
static void qlist_clear(QDeclarativeListProperty *p)
static T * qlist_at(QDeclarativeListProperty *p, int idx)

◆ QDeclarativeListProperty() [6/6]

template<typename T>
QDeclarativeListProperty< T >::QDeclarativeListProperty ( QObject o,
void *  d,
AppendFunction  a,
CountFunction  c = 0,
AtFunction  t = 0,
ClearFunction  r = 0 
)
inline

Definition at line 89 of file qgraphicsitem_p.h.

91  : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
long ASN1_INTEGER_get ASN1_INTEGER * a

Functions

◆ operator==() [1/2]

template<typename T>
bool QDeclarativeListProperty< T >::operator== ( const QDeclarativeListProperty< T > &  o) const
inline

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

Definition at line 77 of file qdeclarativelist.h.

77  {
78  return object == o.object &&
79  data == o.data &&
80  append == o.append &&
81  count == o.count &&
82  at == o.at &&
83  clear == o.clear;
84  }

◆ operator==() [2/2]

template<typename T>
bool QDeclarativeListProperty< T >::operator== ( const QDeclarativeListProperty< T > &  o) const
inline

Definition at line 93 of file qgraphicsitem_p.h.

93  {
94  return object == o.object &&
95  data == o.data &&
96  append == o.append &&
97  count == o.count &&
98  at == o.at &&
99  clear == o.clear;
100  }

◆ qlist_append() [1/2]

template<typename T>
static void QDeclarativeListProperty< T >::qlist_append ( QDeclarativeListProperty< T > *  p,
T *  v 
)
inlinestaticprivate

Definition at line 100 of file qdeclarativelist.h.

100  {
101  reinterpret_cast<QList<T *> *>(p->data)->append(v);
102  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_append() [2/2]

template<typename T>
static void QDeclarativeListProperty< T >::qlist_append ( QDeclarativeListProperty< T > *  p,
T *  v 
)
inlinestaticprivate

Definition at line 116 of file qgraphicsitem_p.h.

116  {
117  ((QList<T *> *)p->data)->append(v);
118  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_at() [1/2]

template<typename T>
static T* QDeclarativeListProperty< T >::qlist_at ( QDeclarativeListProperty< T > *  p,
int  idx 
)
inlinestaticprivate

Definition at line 106 of file qdeclarativelist.h.

106  {
107  return reinterpret_cast<QList<T *> *>(p->data)->at(idx);
108  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_at() [2/2]

template<typename T>
static T* QDeclarativeListProperty< T >::qlist_at ( QDeclarativeListProperty< T > *  p,
int  idx 
)
inlinestaticprivate

Definition at line 122 of file qgraphicsitem_p.h.

122  {
123  return ((QList<T *> *)p->data)->at(idx);
124  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_clear() [1/2]

template<typename T>
static void QDeclarativeListProperty< T >::qlist_clear ( QDeclarativeListProperty< T > *  p)
inlinestaticprivate

Definition at line 109 of file qdeclarativelist.h.

109  {
110  return reinterpret_cast<QList<T *> *>(p->data)->clear();
111  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_clear() [2/2]

template<typename T>
static void QDeclarativeListProperty< T >::qlist_clear ( QDeclarativeListProperty< T > *  p)
inlinestaticprivate

Definition at line 125 of file qgraphicsitem_p.h.

125  {
126  return ((QList<T *> *)p->data)->clear();
127  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_count() [1/2]

template<typename T>
static int QDeclarativeListProperty< T >::qlist_count ( QDeclarativeListProperty< T > *  p)
inlinestaticprivate

Definition at line 103 of file qdeclarativelist.h.

103  {
104  return reinterpret_cast<QList<T *> *>(p->data)->count();
105  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ qlist_count() [2/2]

template<typename T>
static int QDeclarativeListProperty< T >::qlist_count ( QDeclarativeListProperty< T > *  p)
inlinestaticprivate

Definition at line 119 of file qgraphicsitem_p.h.

119  {
120  return ((QList<T *> *)p->data)->count();
121  }
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Properties

◆ append

template<typename T>
AppendFunction QDeclarativeListProperty< T >::append

◆ at

template<typename T>
AtFunction QDeclarativeListProperty< T >::at

◆ clear

template<typename T>
ClearFunction QDeclarativeListProperty< T >::clear

◆ count

template<typename T>
CountFunction QDeclarativeListProperty< T >::count

◆ data

template<typename T>
void * QDeclarativeListProperty< T >::data

◆ dummy1

template<typename T>
void * QDeclarativeListProperty< T >::dummy1

◆ dummy2

template<typename T>
void * QDeclarativeListProperty< T >::dummy2

◆ object

template<typename T>
QObject * QDeclarativeListProperty< T >::object

Definition at line 86 of file qdeclarativelist.h.

Referenced by QDeclarativeTransitionPrivate::animation_at(), QDeclarativeTransitionPrivate::animation_count(), QDeclarativeTransitionPrivate::append_animation(), QDeclarativeAnimationGroupPrivate::append_animation(), QDeclarativeXmlListModelPrivate::append_role(), QDeclarativeStateGroupPrivate::append_state(), QDeclarativeStateGroupPrivate::append_transition(), QDeclarativeStateGroupPrivate::at_state(), QDeclarativeStateGroupPrivate::at_transition(), QDeclarativeVisualItemModelPrivate::children_append(), QGraphicsItemPrivate::children_append(), QGraphicsItemPrivate::children_at(), children_at_helper(), QGraphicsItemPrivate::children_clear(), children_clear_helper(), QGraphicsItemPrivate::children_count(), children_count_helper(), QDeclarativeAnimationGroupPrivate::clear_animation(), QDeclarativeTransitionPrivate::clear_animations(), QDeclarativeXmlListModelPrivate::clear_role(), QDeclarativeStateGroupPrivate::clear_states(), QDeclarativeStateGroupPrivate::clear_transitions(), QDeclarativeContextPrivate::context_at(), QDeclarativeContextPrivate::context_count(), QDeclarativeStateGroupPrivate::count_state(), QDeclarativeStateGroupPrivate::count_transitions(), QDeclarativeItemPrivate::data_append(), QDeclarativeFlickablePrivate::data_append(), QDeclarativeListReferencePrivate::init(), QDeclarativeVMEMetaObject::list_append(), QDeclarativeVMEMetaObject::list_clear(), QDeclarativeListScriptClass::newList(), QDeclarativeStatePrivate::operations_append(), QDeclarativeListProperty< QDeclarativeXmlListModelRole >::operator==(), QDeclarativeItemPrivate::resources_append(), QDeclarativeItemPrivate::resources_at(), QDeclarativeItemPrivate::resources_clear(), QDeclarativeItemPrivate::resources_count(), QDeclarativeItemPrivate::transform_append(), QDeclarativeItemPrivate::transform_at(), QDeclarativeItemPrivate::transform_clear(), and QDeclarativeItemPrivate::transform_count().


The documentation for this class was generated from the following files: