Qml Module Not Found But App is running
-
Hello, I'm getting a problem with qmldir. When I use the qmldir the app is running but qt doesn't show the module.
I added the import path in .pro and also in main.cpp.engine.addImportPath("qrc:/");
When I use the qmldir at another subfile(.pri), why does qt show this error? But there are no problems with component and asset.com modules.
-
@Enes-Alp
this is just a warning in QtCreator. you can tell QtCreator to find imports by setting the QML_IMPORT_PATH qmake variable.
same issue: https://forum.qt.io/topic/132290/import-says-qml-module-not-found -
Thank you, I solved but I have also another problem with registering my custom type to qml.
#include "test.h" #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.addImportPath("qrc:/"); //////////// Test::resgisterType("Rect"); ///////////// const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect( &engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
When registering custom type to qml, qt creator doesn't see the type.
The rect comes from test.h.
-
@Enes-Alp
then its an issue with QtCreator not parsing source files of .pri files