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. QQmlApplicationEngine failed to load component
Forum Updated to NodeBB v4.3 + New Features

QQmlApplicationEngine failed to load component

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 3 Posters 36.3k 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.
  • S Offline
    S Offline
    Suraj26254
    wrote on 19 Oct 2016, 11:27 last edited by p3c0
    #1

    Hello Guy's,
    While building my Qt application I am getting the following error.
    Your kind suggestions are welcome.

    Starting E:\QtCreaterPro\QtCppQml2\debug\QtCppQml2.exe...
    QML debugging is enabled. Only use this in a safe environment.
    QQmlApplicationEngine failed to load component
    qrc:/qml/res/layouts/main.qml:5 Expected type name.

    I am uploading my code , please refer it for further clarification.


    #include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"
    #include <QQmlApplicationEngine>
    #include <QQmlContext>
    #include "datastore.h"
    #include <QtQml>
    
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
    //    QtQuick2ApplicationViewer viewer;
    //    viewer.setMainQmlFile(QStringLiteral("qml/QtCppQml2/main.qml"));
    //    viewer.showExpanded();
        QQmlApplicationEngine engine;
        QQmlContext* context = engine.rootContext();
        Datastore dt;
        context->setContextProperty("dataStore",&dt);
        engine.load(QUrl(QStringLiteral("qrc:/qml/res/layouts/main.qml")));
       // engine.load(QUrl::fromLocalFile("qml/QtCppQml2/main.qml"));
    
    
        return app.exec();
    }
    
    R 1 Reply Last reply 19 Oct 2016, 12:38
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 20 Oct 2016, 04:55 last edited by
      #5

      @Suraj26254 So according to the code at line no.5 it should be Window rather than window. Note: QML types should begin with captial letters.

      157

      1 Reply Last reply
      2
      • P Offline
        P Offline
        p3c0
        Moderators
        wrote on 19 Oct 2016, 11:31 last edited by
        #2

        @Suraj26254 What is at line no. 5 in main.qml ?

        157

        1 Reply Last reply
        2
        • S Suraj26254
          19 Oct 2016, 11:27

          Hello Guy's,
          While building my Qt application I am getting the following error.
          Your kind suggestions are welcome.

          Starting E:\QtCreaterPro\QtCppQml2\debug\QtCppQml2.exe...
          QML debugging is enabled. Only use this in a safe environment.
          QQmlApplicationEngine failed to load component
          qrc:/qml/res/layouts/main.qml:5 Expected type name.

          I am uploading my code , please refer it for further clarification.


          #include <QtGui/QGuiApplication>
          #include "qtquick2applicationviewer.h"
          #include <QQmlApplicationEngine>
          #include <QQmlContext>
          #include "datastore.h"
          #include <QtQml>
          
          
          int main(int argc, char *argv[])
          {
              QGuiApplication app(argc, argv);
          
          //    QtQuick2ApplicationViewer viewer;
          //    viewer.setMainQmlFile(QStringLiteral("qml/QtCppQml2/main.qml"));
          //    viewer.showExpanded();
              QQmlApplicationEngine engine;
              QQmlContext* context = engine.rootContext();
              Datastore dt;
              context->setContextProperty("dataStore",&dt);
              engine.load(QUrl(QStringLiteral("qrc:/qml/res/layouts/main.qml")));
             // engine.load(QUrl::fromLocalFile("qml/QtCppQml2/main.qml"));
          
          
              return app.exec();
          }
          
          R Offline
          R Offline
          Roumed
          wrote on 19 Oct 2016, 12:38 last edited by
          #3

          @Suraj26254 Seem's like your root component has unknown type or bad name.
          Check that imports contains type of root component and type name don't start with e.g. '_' symbol.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Suraj26254
            wrote on 20 Oct 2016, 04:21 last edited by
            #4

            @p3c0 Thanks for replying. Below is the code of main.qml.

            //your code here
            `import QtQuick 2.0
            import QtQuick.Window 2.0
            import QtQuick.Controls 1.0
            
            window {
                visible: true
                width: 100
                height: 62
            
                Connections{
                    target: dataStore
                    onIncreaeOne:txtCount.text.ms
                }
                Text{
                    id: txtCount
                    text: "0 Hits"
                }
                Button{
                    id: btnUpdate
                    anchors.top: txtCount.bottom
                    onClicked:  dataStore.callMeFromQml()
                }
            
            }
            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 20 Oct 2016, 04:55 last edited by
              #5

              @Suraj26254 So according to the code at line no.5 it should be Window rather than window. Note: QML types should begin with captial letters.

              157

              1 Reply Last reply
              2
              • S Offline
                S Offline
                Suraj26254
                wrote on 20 Oct 2016, 05:13 last edited by Suraj26254
                #6

                @Roumed and @p3c0 Thanks a lot for the reply. The problem was with my root component and now error is sloved.
                link text

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 20 Oct 2016, 05:25 last edited by
                  #7

                  @Suraj26254 Window is the root component here.

                  157

                  S 1 Reply Last reply 20 Oct 2016, 08:22
                  1
                  • P p3c0
                    20 Oct 2016, 05:25

                    @Suraj26254 Window is the root component here.

                    S Offline
                    S Offline
                    Suraj26254
                    wrote on 20 Oct 2016, 08:22 last edited by
                    #8

                    @p3c0 Ya right. I got it. And now my code is perfect . Thanks

                    1 Reply Last reply
                    0

                    8/8

                    20 Oct 2016, 08:22

                    • Login

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