diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-07-19 02:20:11 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-07-20 01:45:47 (GMT) |
commit | 8e19cbbad806b710e03ff17e80646e0274cf63cc (patch) | |
tree | 16d09f9875528862fad815013ba26ae28378952b /doc | |
parent | 06ef198e0812b514c261ef8f7c82db754450f1fa (diff) | |
download | Qt-8e19cbbad806b710e03ff17e80646e0274cf63cc.zip Qt-8e19cbbad806b710e03ff17e80646e0274cf63cc.tar.gz Qt-8e19cbbad806b710e03ff17e80646e0274cf63cc.tar.bz2 |
Change docs to show how to define enum properties
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/declarative/extending-tutorial.qdoc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index cc93e86..bc849b0 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -260,20 +260,34 @@ custom QML types may see unexpected behavior if bindings are not implemented. \example declarative/tutorials/extending/chapter4-customPropertyTypes The \c PieChart type currently has a string-type property and a color-type property. -It could have many other types of properties. For example, we could add an -integer-type property to store an identifier for each pie chart: +It could have many other types of properties. For example, it could have an +enum-type property to store a display mode for each chart: \code + // C++ class PieChart : public QDeclarativeItem { + Q_ENUMS(DisplayMode) + Q_PROPERTY(DisplayMode displayMode READ displayMode WRITE setDisplayMode) ... - Q_PROPERTY(int id READ id WRITE setId) + public: - ... - int id() const; - void setId(int id); + enum DisplayMode { + MultiLevel, + Exploded, + ThreeDimensional + }; + + void setDisplayMode(DisplayMode mode); + DisplayMode displayMode() const; ... }; + + // QML + PieChart { + ... + displayMode: PieChart.Exploded + } \endcode We can also use various other property types. QML has built-in support for the following |