diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2022-12-21 16:31:20 +0100 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-01-06 18:28:31 +0100 |
commit | 3df8eba0f5e9f9b0142914d53c1183c5a05030e7 (patch) | |
tree | c7b9be965fa265823904155c66afb372285db6e3 /src/qml/doc | |
parent | 4e1fe071ff05b92ed12fdf59a2185e1254b411cf (diff) |
qmltc: generate code into namespaces
Generate code into namespaces to avoid clashes between qmltc-generated
and user code. Code generated by qmltc will by default be put in the
URI_OF_MODULE namespace, and will generate subnamespaces
to follow the module hierarchy if URI_OF_MODULE contains dots('.').
Also fix the test to use the new namespaces.
[ChangeLog][Qml][qmltc] The type compiler will generate C++-code into
a namespace by default. The new default namespace is inferred from
the module's URI, where dots are interpreted as separating subnamespaces
from each other,
e.g., a type in module MyCompany.MyModule.Sub will be generated in the namespace
MyCompany::MyModule::Sub.
Fixes: QTBUG-109274
Change-Id: I3bfe2697b81e90bb63a079dc44c2810fc9925f97
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/doc')
-rw-r--r-- | src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp | 2 | ||||
-rw-r--r-- | src/qml/doc/src/cmake/qt_add_qml_module.qdoc | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp b/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp index a78da416e2..7bda70f985 100644 --- a/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp +++ b/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp @@ -53,7 +53,7 @@ void tst_qmltc_examples::app() QQmlEngine e; QQuickWindow window; - QScopedPointer<myApp> documentRoot(new myApp(&e)); + QScopedPointer<QmltcExample::myApp> documentRoot(new QmltcExample::myApp(&e)); documentRoot->setParentItem(window.contentItem()); window.setHeight(documentRoot->height()); diff --git a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc index 9bef299970..7617d19033 100644 --- a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc +++ b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc @@ -655,4 +655,15 @@ with \l{QML Type Compiler}{qmltc}. Files with the source property C++ code resides. By default, no namespace is specified for user projects. The code generated from Qt's own sources is put under a QT_NAMESPACE namespace. +\c TYPE_COMPILER_NAMESPACE argument allows to override the namespace in which +\l{QML Type Compiler}{qmltc} generates code. +By default, the namespace of the generated code follows the module +hierarchy as depicted in the URI, +e.g., \c MyModule for a module with URI \c MyModule or +\c com::example::Module for URI \c com.example.MyModule. +By specifying the \c TYPE_COMPILER_NAMESPACE option, the generated code +can be put instead in a custom namespace, where different subnamespaces are to +be separated by a "::", e.g. "MyNamespace::MySubnamespace" for the namespace MySubnamespace that +is inside the MyNamespace. Apart from the "::", C++ namespace naming rules +apply. */ |