aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/Qt6QmlMacros.cmake7
-rw-r--r--src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp2
-rw-r--r--src/qml/doc/src/cmake/qt_add_qml_module.qdoc11
3 files changed, 18 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 2f7659c2a0..c0df7a92f0 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -664,10 +664,15 @@ function(qt6_add_qml_module target)
endif()
if (arg_ENABLE_TYPE_COMPILER)
+ if (DEFINED arg_TYPE_COMPILER_NAMESPACE AND NOT $<STREQUAL:"${arg_TYPE_COMPILER_NAMESPACE}","">)
+ set(qmltc_namespace ${arg_TYPE_COMPILER_NAMESPACE})
+ else()
+ string(REPLACE "." "::" qmltc_namespace "${arg_URI}")
+ endif()
_qt_internal_target_enable_qmltc(${target}
QML_FILES ${arg_QML_FILES}
IMPORT_PATHS ${arg_IMPORT_PATH}
- NAMESPACE ${arg_TYPE_COMPILER_NAMESPACE}
+ NAMESPACE ${qmltc_namespace}
)
endif()
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.
*/