Description
When compiling a library with Qt.qml.importName set (which triggers qmltyperegistrar), I receive multiple warnings from the tool about missing Qt types. A typical warning looks like:
"QObject is used as base type but cannot be found."
This appears to be caused by qmltyperegistrar not being passed the correct --foreign-types arguments. From what I can tell, QBS attempts to resolve the metatypes JSON file in the following way (see share/qbs/module-providers/Qt/setup-qt.js):
var metaTypesFile = qtProps.libraryPath + "/metatypes/qt" + qtProps.qtMajorVersion + module.qbsName + "_metatypes.json";
However, in my setup (installed via the Qt Maintenance Tool), the installed file has a different name:
6.5.6/gcc_64/metatypes/qt6core_relwithdebinfo_metatypes.json
Notice the relwithdebinfo infix, which causes the file to be missed during resolution. As a result, the qmltyperegistrar does not receive the necessary type information, leading to these warnings.
This workaround fixes the issue for me:
readonly property string _qtCoreMetatypesPath: Qt.core.installPrefixPath + "/metatypes/qt" + Qt.core.versionMajor + "core_relwithdebinfo_metatypes.json" Qt.qml.extraMetaTypesFiles: File.exists(_qtCoreMetatypesPath) ? [ _qtCoreMetatypesPath ] : []
Attachments
For Gerrit Dashboard: QBS-1840 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
643319,3 | Qt support: Adapt to metatype file name changes in Qt 6 | 3.0 | qbs/qbs | Status: MERGED | +2 | +1 |