Use QT_{BEGIN,END}_NAMESPACE when building Qt::OpenApiCommon
We need to use the proper Qt macros in order to make moc happy
when we're building the OpenApiCommon library as a part of Qt.
However, these macros should not be used when users builds all
the code on their own.
To solve the issue, we introduce a new "hidden" property into
the Java generator. This property is only set to true when the
qt_add_openapi_client() macro is used to build the common lib,
because this means that we're building the common lib as a part
of the Qt build.
Later this new property is used in the templates to generate the
code that is only available when building Qt.
This allows us to reintroduce the full namespace in the base
class specification in api-header.mustache, and thus get rid of
the qmltyperegistrar warning about a base type being used but not
found and other related qmllint warnings that were seen when
building the colorpalette example.
Fixes: QTBUG-142567
Pick-to: 6.11
Change-Id: I772d67edd90aed4683b1622582f39e3ab6494276
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
| commit | 3a21742fb66cd54d52cfd209d77445f482281a97 |
| parent | da8ad6648a943b4e54ea38fb7bb423a36d9cbece |
| author | Ivan Solovev <ivan.solovev@qt.io> |
| committer | Ivan Solovev <ivan.solovev@qt.io> |
| commit time | Tue, 13 Jan 2026 14:58:18 +0100 |
- M src/openapi/Qt6OpenApiToolsGeneratorMacros.cmake
- M src/tools/qtopenapi-generator/src/main/java/org/qtproject/qt/codegen/CppQt6ClientGenerator.java
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/api-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/enum-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/enum-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/helpers-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/helpers-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httpfileelement.cpp.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httpfileelement.h.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httprequest.cpp.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httprequest.h.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/object-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/object-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/serverconfiguration.cpp.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/serverconfiguration.h.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/servervariable.cpp.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/servervariable.h.mustache