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. (Qt5.15.0 + Qt Creator 4.12.4) Qml Module not found - Integrating QML and C++
Forum Updated to NodeBB v4.3 + New Features

(Qt5.15.0 + Qt Creator 4.12.4) Qml Module not found - Integrating QML and C++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml
17 Posts 15 Posters 9.0k Views 5 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.
  • S Offline
    S Offline
    Shazter
    wrote on 20 Jul 2020, 17:05 last edited by
    #1

    Hello, based on the Integrating QML and C++ I made the registration for the C++ Class, but Qt Creator reports the error "Qml Module not found". I made a breakpoint into the C++ Class and executed a Debug session and by Textchange the breakpoint gets hit, means the Module is found.

    How I solve the Error Message, because is annoying and code completion doesn't work

    Operationsystem: Windows 10
    Qt Version: Qt5.15.0
    Qt Creator: 4.12.4
    ompiler: MSVC2019 64Bit

    Pro file:

    QT += quick
    
    CONFIG += c++11
    
    CONFIG += qmltypes
    QML_IMPORT_NAME = io.qt.examples.backend
    QML_IMPORT_MAJOR_VERSION = 1
    
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Refer to the documentation for the
    # deprecated API to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            backend.cpp \
            main.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        backend.h
    

    backend.cpp

    #include "backend.h"
    
    BackEnd::BackEnd(QObject *parent) :
        QObject(parent)
    {
    }
    
    QString BackEnd::userName()
    {
        return m_userName;
    }
    
    void BackEnd::setUserName(const QString &userName)
    {
        if (userName == m_userName)
            return;
    
        m_userName = userName;
        emit userNameChanged();
    }
    

    backend.h:

    #ifndef BACKEND_H
    #define BACKEND_H
    
    #include <QObject>
    #include <QString>
    #include <qqml.h>
    
    class BackEnd : public QObject
    {
        Q_OBJECT
        Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged)
        QML_ELEMENT
    
    public:
        explicit BackEnd(QObject *parent = nullptr);
    
        QString userName();
        void setUserName(const QString &userName);
    
    signals:
        void userNameChanged();
    
    private:
        QString m_userName;
    };
    
    #endif // BACKEND_H
    

    main.qml:

    Line 3 "import io.qt.examples.backend 1.0" I get the error Qml Module not found

    import QtQuick 2.6
    import QtQuick.Controls 2.0
    import io.qt.examples.backend 1.0
    
    ApplicationWindow {
        id: root
        width: 300
        height: 480
        visible: true
    
        BackEnd {
            id: backend
        }
    
        TextField {
            text: backend.userName
            placeholderText: qsTr("User name")
            anchors.centerIn: parent
    
            onTextChanged: backend.userName = text
        }
    }
    

    This file gets generated:

    [
        {
            "classes": [
                {
                    "classInfos": [
                        {
                            "name": "QML.Element",
                            "value": "auto"
                        }
                    ],
                    "className": "BackEnd",
                    "object": true,
                    "properties": [
                        {
                            "constant": false,
                            "designable": true,
                            "final": false,
                            "name": "userName",
                            "notify": "userNameChanged",
                            "read": "userName",
                            "required": false,
                            "scriptable": true,
                            "stored": true,
                            "type": "QString",
                            "user": false,
                            "write": "setUserName"
                        }
                    ],
                    "qualifiedClassName": "BackEnd",
                    "signals": [
                        {
                            "access": "public",
                            "name": "userNameChanged",
                            "returnType": "void"
                        }
                    ],
                    "superClasses": [
                        {
                            "access": "public",
                            "name": "QObject"
                        }
                    ]
                }
            ],
            "inputFile": "backend.h",
            "outputRevision": 67
        }
    ]
    
    1 Reply Last reply
    5
    • S Offline
      S Offline
      Shazter
      wrote on 21 Jul 2020, 19:10 last edited by
      #2

      Hello, does somebody can confirm same issue?

      M 1 Reply Last reply 13 Sept 2020, 22:05
      0
      • N Offline
        N Offline
        nminkov
        wrote on 29 Jul 2020, 13:08 last edited by
        #3

        I am not sure it's the same issue, but I have a similar problem, but in my QML I explicitely use 2.15 module import ("import QtQuick 2.15")

        I can see in QT Creator, menu Help->System information... that QT creator is built against QT 5.14.2, so if I change my QTQuick version to 2.14 in QML import, it works.

        That is, it seems that the import supported version depends from QT Creator QT build version, which is weird. If so, guys, please rebuilt QT Creator always with latest QT version, so 5.15 in this case.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Shazter
          wrote on 12 Aug 2020, 17:47 last edited by
          #4

          Checked again my Qt Creator Version and is "Based on Qt 5.14.2". I'm not able to build Qt Creator against 5.15.0 by myself, means I cannot confirm is solves the Problem.

          1 Reply Last reply
          0
          • S Shazter
            21 Jul 2020, 19:10

            Hello, does somebody can confirm same issue?

            M Offline
            M Offline
            Michael Scopchanov
            wrote on 13 Sept 2020, 22:05 last edited by
            #5

            @Shazter I have the exact same issue.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              brai
              wrote on 14 Oct 2020, 20:30 last edited by
              #6

              I am experiencing the same issue with Qt Creator 4.13.0 (based on Qt 5.15.0 MSVC 2019, 64 bit)

              1 Reply Last reply
              0
              • W Offline
                W Offline
                WatermelonJesus
                wrote on 15 Oct 2020, 02:27 last edited by WatermelonJesus
                #7

                Same problem. Came here to ask it. I'm even using the exact same example which is found here. Original link in the question is a 404.

                Qt Creator 4.13.2
                Based on Qt 5.15.1 (MSVC 2019, 64 bit)
                Built on Oct 1 2020 01:14:56

                Some more info for my case:

                • I get the "QML Module error not found" but not in output, only in the QtCreator text editor. Project still runs and builds fine.
                • Ctrl + Space intellisense or whatever its called doesn't recognize the module, and it is shown in gray as in an unrecognized keyword, all while actually working
                • I get two warnings. Both are identical: -1: warning: Failure to find: testcustommodule_metatypes.json. My project is called TestCustomModule.
                • While compiling QtCreator adds a subfolder to my Sources which is a full local path and within it is a single file: testcustommodule_metatypes.json. I hate this.

                Tried importing different QtQuick modules as suggested; no effect. Is there a solution to this yet? Feels like it might have something to do with QML_IMPORT_PATH

                For now I'm going back to the old school qmlRegisterType method. But I'd love to get this working.

                1 Reply Last reply
                1
                • R Offline
                  R Offline
                  Rivvil
                  wrote on 30 Oct 2020, 23:21 last edited by
                  #8

                  Have exactly the same issue.

                  Qt Creator 4.13.2
                  Based on Qt 5.15.1 (MSVC 2019, 64 bit)
                  Built on Oct 1 2020 01:14:56

                  My application seems to work fine, but Library area with available QML Types in Design tab "dies" everytime I try to edit a QML file with pseudo-erroneous import. It doesn't react to clicks and scrolling.

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    Oleg R.
                    wrote on 2 Nov 2020, 12:58 last edited by
                    #9

                    Same issue here. Tried the Beta Qt Creator with no success. If I choose Android project and build it, the error disappears, but still Form designer does not show form correctly.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alaiseca
                      wrote on 14 Nov 2020, 09:58 last edited by
                      #10

                      Exactly the same issues described by other posters. I have upgraded Qt Creator to the latest available version (4.13.2), and also updated to 5.15.1 hoping this to solve the problem, but no luck so far. It's disappointing to see how much time has passed since these issues were initially reported with the Qt staff remaining just silent

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        LucyNoodles20
                        wrote on 25 Nov 2020, 15:21 last edited by
                        #11

                        I'm having the same issue as well.

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jay1
                          wrote on 11 Jan 2021, 19:48 last edited by
                          #12

                          I am also facing the same issue, is this issue resolved or can anyone points to the solution

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            chipolux
                            wrote on 13 Jan 2021, 00:55 last edited by
                            #13

                            Also experiencing the same issue. There is an open bug report here: https://bugreports.qt.io/browse/QTCREATORBUG-24987

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              dataxelio
                              wrote on 27 Jan 2021, 19:07 last edited by dataxelio
                              #14

                              Hello,
                              I'm having same issue with Qt6.0.1 and Qt Creator 4.14
                              But the application still run successfully. Just got this ennoying error (QML module not found) from Qt Creator and also the subfolder with the full path to xxxx_metatypes.json (as described in a post above)

                              Can someone from Qt help on this please ?
                              Is it a bug on Qt Creator ?

                              Thanks.

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                Tyrannic
                                wrote on 3 Feb 2021, 17:14 last edited by Tyrannic 2 Mar 2021, 17:15
                                #15

                                Also having this problem on 5.15.2, Qt Creator 4.14.0.

                                I have local classes with the proper QML_ELEMENT macro in them, along with the proper QML_IMPORT_NAME and QML_IMPORT_MAJOR_VERSION defined. The code runs fine with the QML_IMPORT_PATH set to $$PWD, but the QML documents are still getting highlighted in QtCreator as not being able to find the module.

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  Joee
                                  wrote on 31 May 2021, 10:06 last edited by
                                  #16

                                  Hello,

                                  I have the same issue with the Qt5.15.2 and Qt Creator 4.14.2

                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    JR_Techno
                                    wrote on 15 Sept 2021, 15:20 last edited by
                                    #17

                                    I could resolve this problem.
                                    On the machine where i install the sofware, i download corresponding QT (example : 5.15.2) with QT Creator.
                                    I link the Qml path with the sources :

                                    qputenv("QML2_IMPORT_PATH", QString("/home/USER_NAME/Qt/5.15.2/gcc_64/qml").toLatin1());
                                    

                                    and it's work.
                                    You can move/export le qml folder to!

                                    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