diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-05-10 09:44:51 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-05-11 09:38:03 +0000 |
commit | 2f09971fd6c7c6781aca24371ebbad39ebcb0df9 (patch) | |
tree | 503719bf1773c5a44911362c568223195ccd4660 /src/qml | |
parent | 922edbb930a46712c06638db246d58262c34f318 (diff) |
Doc: Clarify preconditions for using QML_ELEMENT et al
You need to include qqml.h and you need to make your own class
declarations available to the registration code.
Change-Id: I98e6b0b8a0acc309482416c3137d8ed782bbdc82
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 40c759cbfa9dfb944a924b6c01fbfd1a15a7a25e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/doc/src/cppintegration/definetypes.qdoc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc index 2fdd6edded..aeff2b5776 100644 --- a/src/qml/doc/src/cppintegration/definetypes.qdoc +++ b/src/qml/doc/src/cppintegration/definetypes.qdoc @@ -70,6 +70,21 @@ exposed to QML but the type itself should not be instantiable. For a quick guide to choosing the correct approach to expose C++ types to QML, see \l {Choosing the Correct Integration Method Between C++ and QML}. +\section2 Preconditions + +All the macros mentioned below are available from the \c qqml.h +header. You need to add the following code to the files using them in order to +make the macros available: + +\code +#include <QtQml/qqml.h> +\endcode + +Furthermore, your class declarations have to live in headers reachable via your +project's include path. The declarations are used to generate registration code +at compile time, and the registration code needs to include the headers that +contain the declarations. + \section2 Registering an Instantiable Object Type \b{Any QObject-derived C++ class can be registered as the definition of a |