aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/modules/cppplugins.qdoc
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-05-28 17:12:56 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-21 09:58:56 +0200
commit5e33b0f580d2b20f1a2989bf2ee8dde4525a2e39 (patch)
tree780d25ce7d8955e56ea985a35dd84609df12fbf0 /src/qml/doc/src/modules/cppplugins.qdoc
parent03342a435a88656d64d1445991a4421d244fcb45 (diff)
Create new documentation structure
The documentation currently has no clear separation between Qt QML and Qt Quick. With recent commits like: 6c8378eaf1edbbefe6aaa3672b0127816a004fd7 and ab1e510121c8a679fdaca12ccd30e0f7ac12a26b the separation between the language definition and implementation, provided by Qt QML, and the standard library for the QML language, provided by Qt Quick, is clear. This commit creates a new documentation structure that is more navigable and separates concepts into logical categories, with clear separation between QtQML and QtQuick. It also provides a more generic QML Application Developer Resources page which contains links to information for QML application developers. Change-Id: Ia807ccfbfd24ffa0e1c7f0a51ed9d2ed3aa6a733 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/doc/src/modules/cppplugins.qdoc')
-rw-r--r--src/qml/doc/src/modules/cppplugins.qdoc134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/qml/doc/src/modules/cppplugins.qdoc b/src/qml/doc/src/modules/cppplugins.qdoc
new file mode 100644
index 0000000000..d8729d6c97
--- /dev/null
+++ b/src/qml/doc/src/modules/cppplugins.qdoc
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qtqml-modules-cppplugins.html
+\title Creating C++ Plugins For QML
+\brief Description of how to write C++ plugins for QML
+
+\section1 Creating A Plugin
+
+ The \l{QQmlEngine}{QML engine} load C++ plugins for QML.
+ Such plugins are usually provided in a QML extension module, and can
+ provide types and functionality for use by clients in QML documents
+ which import the module.
+
+ QQmlExtensionPlugin is a plugin interface that makes it possible to
+ create QML extensions that can be loaded dynamically into QML applications.
+ These extensions allow custom QML types to be made available to the
+ QML engine.
+
+ To write a QML extension plugin:
+ \list 1
+ \li Subclass QQmlExtensionPlugin
+ \li Implement QQmlExtensionPlugin's
+ \l{QQmlExtensionPlugin::}{registerTypes()} method
+ \li Register types with qmlRegisterType()
+ \li Export the class using the Q_EXPORT_PLUGIN2() macro
+ \li Write a project file for the plugin
+ \li Create a \l{Syntax of a qmldir file}{qmldir file} to describe the plugin
+ \endlist
+
+ QML extension plugins are for either application-specific or library-like
+ plugins. Library plugins should limit themselves to registering types, as
+ any manipulation of the engine's root context may cause conflicts or other
+ issues in the library user's code.
+
+\section1 Plugin Example
+
+ Suppose there is a new \c TimeModel C++ class that should be made available
+ as a new QML element. It provides the current time through \c hour and \c minute
+ properties.
+
+ \snippet examples/qml/cppextensions/plugins/plugin.cpp 0
+ \dots
+
+ A plugin class, \c QExampleQMLPlugin, is a subclass of
+ \l QQmlExtensionPlugin and it implements the
+ \l{QQmlExtensionPlugin::}{registerTypes()} method.
+
+ In the registerTypes() method, the plugin class can
+ register the \c TimeModel class to the declarative
+ runtime with the qmlRegisterType() function. The Q_EXPORT_PLUGIN2() macro has
+ two parameters, the generated plugin name and the class name.
+
+ \snippet examples/qml/cppextensions/plugins/plugin.cpp plugin
+ \codeline
+ \snippet examples/qml/cppextensions/plugins/plugin.cpp export
+
+ The \c TimeModel class receives a \c{1.0} version of this plugin library, as
+ a QML type called \c Time. The Q_ASSERT() macro can ensure the module is
+ imported correctly by any QML components that use this plugin. The
+ \l{Defining QML Object Types from C++} article has more information about registering C++
+ types into the runtime.
+
+ For this example, the TimeExample source directory is in
+ \c{com/nokia/TimeExample}. The plugin's module import statement will follow
+ this structure.
+
+ The project file, in a \c .pro file, defines the project as a plugin library
+ and specifies it should be built into the \c com/nokia/TimeExample
+ directory:
+
+ \code
+ TEMPLATE = lib
+ CONFIG += qt plugin
+ QT += declarative
+
+ DESTDIR = com/nokia/TimeExample
+ TARGET = qmlqtimeexampleplugin
+ ...
+ \endcode
+
+ Finally, a \l{Syntax of a qmldir file}{qmldir file} is required in the \c
+ com/nokia/TimeExample directory to specify the plugin. This directory
+ includes a \c Clock.qml file that should be bundled with the plugin, so it
+ needs to be specified in the \c qmldir file:
+
+ \quotefile examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir
+
+ Once the project is built and installed, the new \c Time component is
+ accessible by any QML component that imports the \c com.nokia.TimeExample
+ module
+
+ \snippet examples/qml/cppextensions/plugins/plugins.qml 0
+
+ The full source code is available in the \l {qml/cppextensions/plugins}{plugins example}.
+
+
+\section1 Reference
+
+ \list
+ \li \l {Tutorial: Extending QML with C++} - contains a chapter
+ on creating QML plugins.
+ \li \l{Defining QML Object Types from C++} - information about registering C++ types into
+ the runtime.
+ \li \l{How to Create Qt Plugins} - information about Qt plugins
+ \endlist
+
+
+*/