New file fails to register to QML module - how to debug?
-
wrote on 18 Feb 2025, 14:13 last edited by
I have added one more to many C++ files that register to a QML module due to be added to the SOURCES of qt_qml_add_module (we're talking cmake here).
Just like any other of my similar files, it
- derives from QObject
- has Q_OBJECT
- has QML_ELEMENT
However, this file does not get added to the generated *qmltyperegistrations.cpp files with a "qmlRegisterTypesAndRevisions" entry, like everything else.
I do not see any warnings during build that could shed light on this. How does one gather more information on why this file specifically does not get registered to qml?
Obviously, this is not something I can reproduce in a small project - after all, I had >200 files properly registered before this happened for the first time...
-
Do additional files also fail to register?
If you remove one existing file does it still fail? -
wrote on 19 Feb 2025, 14:10 last edited by
Well, I can play around. But is there
- no way to enable some kind of tracing for this?
- no documentation explaining exactly under which circumstances things get added, and when not?
-
wrote on 20 Feb 2025, 06:50 last edited by
Did you make sure to
target_include_directories(${PROJECT_NAME} PRIVATE src/path/to/c++_qml_element )
for that file?
-
wrote on 20 Feb 2025, 08:46 last edited by
It was the same for the new file as for all the others.
But there is a subtle different I did not find documented anywhere:You have to
#include <QQmlEngine>
otherwise it silently fails
-
-
It was the same for the new file as for all the others.
But there is a subtle different I did not find documented anywhere:You have to
#include <QQmlEngine>
otherwise it silently fails
wrote on 20 Feb 2025, 10:04 last edited by -
wrote on 20 Feb 2025, 10:36 last edited by
@Redman Thanks, but unfortunately, there is no portable version of this header file available...
1/7