Incompatibility Between QT Design Studio and Incorporating C++?
-
I'm rather rusty with QML and C++, so I've been reading some of the documentation. I'm trying to understand the reason behind this note "Note: Uncheck the With ui.qml file option in the Define Project Details section of New Project Wizard." in the document "Integrating QML and C++".
I've been experimenting with using QML_ELEMENT with a C++ class so that I can use it in my QML files (not necessarily the ui files). However if I create the class and initialize it in main.cpp (and insert a qt_add_qml_module statement with the class files under "SOURCES" in my CMakeLIsts.txt file), I get an error thrown in a generated file saying that it cannot find the class header file:
C:/Users/georg/workspace/build-test3-Desktop_Qt_6_6_1_MinGW_64_bit-Debug/test3app_qmltyperegistrations.cpp:10:10: fatal error: testqmlelement.h: No such file or directory 10 | #include <testqmlelement.h> | ^~~~~~~~~~~~~~~~~~ compilation terminated.
So it seems that the "note" is correct. However, I'm at a loss as to why this is.
Why can't one use a Qt Design Studio project with C++ code? Or am I missing something.FYI, I've watch the excellent series on Youtube regarding QML programming and in particular, the video on registering a C++ class with QML, but it doesn't address this issues.