diff options
Diffstat (limited to 'doc/src/declarative/extending-tutorial.qdoc')
-rw-r--r-- | doc/src/declarative/extending-tutorial.qdoc | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index cc93e86a8a..d128d0f77f 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 @@ -407,7 +421,7 @@ To create a plugin library, we need: \list \o A plugin class that registers our QML types \o A project file that describes the plugin -\o A "qmldir" file that tells the QML engine to load the plugin +\o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin \endlist First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin @@ -427,8 +441,8 @@ and specifies with DESTDIR that library files should be built into a "lib" subdi \quotefile declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro -Finally, we add a \c qmldir file that is automatically parsed by the QML engine. -Here, we specify that a plugin named "chapter6-plugin" (the name +Finally, we add a \l{Writing a qmldir file}{qmldir} file that is automatically parsed by the QML engine. +In this file, we specify that a plugin named "chapter6-plugin" (the name of the example project) can be found in the "lib" subdirectory: \quotefile declarative/tutorials/extending/chapter6-plugins/qmldir |