Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml Module Not Found But App is running
Forum Updated to NodeBB v4.3 + New Features

Qml Module Not Found But App is running

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 7.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Enes Alp
    wrote on last edited by
    #1

    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.

    176b0d0b-d6f0-4aaa-b2de-200c073e0001-image.png
    69469878-10e9-4b91-9109-d75bef9e8512-image.png

    raven-worxR 1 Reply Last reply
    0
    • E Enes Alp

      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.

      176b0d0b-d6f0-4aaa-b2de-200c073e0001-image.png
      69469878-10e9-4b91-9109-d75bef9e8512-image.png

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Enes Alp
        wrote on last edited by
        #3

        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.
        0ffd9c25-1b07-4b80-8ab9-d1d161fd958c-image.png
        f2bf2e14-8be6-4e05-a186-32c0e6998d2d-image.png

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Enes Alp
          wrote on last edited by
          #4

          When I register in main.cpp, therre is no problem.

          qmlRegisterType<Test>("Rect", 1, 0, "Test");
          

          but in the .pri file that is problem.

          raven-worxR 1 Reply Last reply
          0
          • E Enes Alp

            When I register in main.cpp, therre is no problem.

            qmlRegisterType<Test>("Rect", 1, 0, "Test");
            

            but in the .pri file that is problem.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @Enes-Alp
            then its an issue with QtCreator not parsing source files of .pri files

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved