Precompiling QML / Recommended resources for Cmake and QML projects
-
Made some progress with precompiling QML for a number of modules but I'm stuck with making it work with a button module, making use of QtQuick controls
Posted about it on Stack Overflow
https://stackoverflow.com/questions/79309283/cant-compile-the-qml-base-type-button-to-c-because-it-lives-in-qtquick-conThe error I had was
import\qml_module\ButtonsModule\ButtonBase.qml:5: error: Can't compile the QML base type "Button" to C++ because it lives in "QtQuick.Controls.Material" instead of the current file's "ButtonsModule" QML module. [compiler]
Does anyone have any idea what this error message is referring to and how I might be able to get past it? Wondering as well if there any recommended resources where all of this is documented. Like Cmake for mobile development projects using QML.
-
Hi @Kory, this is a current limitation of the QML Type Compiler: https://doc.qt.io/qt-6/qtqml-qml-type-compiler.html#known-limitations
Imported QML modules that consist of QML-defined types (such as QtQuick.Controls) might not get compiled correctly, even if those QML-defined types were compiled by qmltc.. At present, you can reliably use QtQml and QtQuick modules as well as any other QML module that only contains C++ classes exposed to QML.
Note: The Type Compiler is only one part of precompilation. You can still use the Script Compiler: https://doc.qt.io/qt-6/qtqml-qml-script-compiler.html