How can I tell if my qml files are actually compiled in to my app?
-
I suspect my qml files specified in the CMakeLists.txt for the app itself (not a separate qml module) are not getting into the qrc system. I've been converting Qt5-based code to work with Qt6 and in the process of converting from the old
qtquick_compiler_add_resources(RESOURCES myqrc.qrc)
to the equivalent
qt_add_qml_module()
call. However, while the previous method worked fine and the files ended up in the appropriate qrc:/qml/myFile.qml area, I have qml codegen errors when compiling the same files. Those files compile just fine with Qt5's CMake API.
I suspect that the codegen errors prevent inclusion of the compiled output in the qrc system.
Here's a sample of those errors:
[1482/1513 55.2/sec] Generating .rcc/qmlcache/PerMain_qml/main_qml.cpp qml.compiler.cppcodegen: main.qml:24: Could not compile signal handler for activeFocusItemChanged: The signal does not exist qml.compiler.cppcodegen: main.qml:102: Could not compile function createAlwaysOnTopComponents: Cannot access value for name BCFunctional qml.compiler.cppcodegen: main.qml:111: Could not compile function showMaterialDialog: Cannot access value for name BCFunctional qml.compiler.cppcodegen: main.qml:120: Could not compile signal handler for closing: The signal does not exist qml.compiler.cppcodegen: main.qml:139: Could not compile function componentCompleted: Cannot access value for name BQFeatures qml.compiler.cppcodegen: main.qml:149: Could not compile binding for changePrinterLanguage: Cannot access value for name BQDisplayPreferences qml.compiler.cppcodegen: main.qml:152: Could not compile binding for onChangePrinterLanguageChanged: Cannot access value for name BQLanguageSupport qml.compiler.cppcodegen: main.qml:38: Could not compile binding for rotation: Cannot access value for name BCDisplayHelper qml.compiler.cppcodegen: main.qml:49: Could not compile binding for width: The property does not exist qml.compiler.cppcodegen: main.qml:51: Could not compile signal handler for buttonPressed: The signal does not exist qml.compiler.cppcodegen: main.qml:52: Could not compile signal handler for jumpToAppWithArgs: The signal does not exist qml.compiler.cppcodegen: main.qml:50: Could not compile binding for top: The property does not exist qml.compiler.cppcodegen: main.qml:59: Could not compile binding for height: The property does not exist qml.compiler.cppcodegen: main.qml:60: Could not compile binding for width: The property does not exist qml.compiler.cppcodegen: main.qml:62: Could not compile signal handler for displayMaterialDialog: The signal does not exist qml.compiler.cppcodegen: main.qml:63: Could not compile signal handler for jumpToAppWithArgs: The signal does not exist qml.compiler.cppcodegen: main.qml:58: Could not compile binding for bottom: The property does not exist qml.compiler.cppcodegen: main.qml:69: Could not compile binding for top: The property does not exist qml.compiler.cppcodegen: main.qml:70: Could not compile binding for bottom: The property does not exist qml.compiler.cppcodegen: main.qml:71: Could not compile binding for left: The property does not exist qml.compiler.cppcodegen: main.qml:72: Could not compile binding for right: The property does not exist qml.compiler.cppcodegen: main.qml:79: Could not compile binding for visible: The property does not exist qml.compiler.cppcodegen: main.qml:84: Could not compile binding for visible: The property does not exist
Am I correct that these compile problems are preventing the various qml files from being accessible at runtime from the expected qrc:/MyApp/main.qml location? If so, why am I running into all these errors when the compile just fine with qtquick_compiler_add_resources()?
-
@Rich-v said in How can I tell if my qml files are actually compiled in to my app?:
to the equivalent
qt_add_qml_module()since you said you are not building a module this is not the equivalent method
you might rather want this: https://doc.qt.io/qt-6/resources.html#build-system-integration
-
@raven-worx
The blog here [1] seemed to indicate that the main program was a module just as the "extra module" was a module. I'm just trying to offer justification for trying what I did. Here's what that blog prescribed:qt_add_executable(main_program main.cpp) qt_add_qml_module(main_program VERSION 1.0 URI myProject QML_FILES main.qml SOURCES onething.cpp onething.h )
It's also mentioned on the page you linked that qt_add_qml_module is an option:
Finally, qt_add_qml_module allows you to embed Qt Quick resources into the resource system of your application. The function is defined in the Qml component of the Qt6 CMake package.
I don't fully understand if the options listed at the URL you provided are all created equal or if there are only certain circumstances when you should use qt_add_qml_module.