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
QtWS25 Last Chance

QQmlApplicationEngine failed to load component

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 3 Posters 2.2k Views
  • 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.
  • P Offline
    P Offline
    Pr0y
    wrote on 5 Jul 2022, 04:42 last edited by
    #1

    This is the error I am getting
    QQmlApplicationEngine failed to load component
    qrc:/Test_C/main.qml:13:5: CircularProgressBar is not a type
    QML debugging is enabled. Only use this in a safe environment.

    Code:
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    const QUrl url(u"qrc:/Test_C/main.qml"_qs);
    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();
    

    }

    import QtQuick
    import QtQuick.Window
    import QtQuick.Controls
    import Qt5Compat.GraphicalEffects

    Window {
    visible: true
    color: "#55557f"
    width: 800
    height: 480
    title: qsTr("Hello World")

    CircularProgressBar{
        id:progress1
        x: 49
        y: 79
        value:10
        progressColor:"Blue"
    

    }
    }

    J 1 Reply Last reply 5 Jul 2022, 05:11
    0
    • P Pr0y
      5 Jul 2022, 04:42

      This is the error I am getting
      QQmlApplicationEngine failed to load component
      qrc:/Test_C/main.qml:13:5: CircularProgressBar is not a type
      QML debugging is enabled. Only use this in a safe environment.

      Code:
      #include <QGuiApplication>
      #include <QQmlApplicationEngine>

      int main(int argc, char *argv[])
      {
      QGuiApplication app(argc, argv);

      QQmlApplicationEngine engine;
      const QUrl url(u"qrc:/Test_C/main.qml"_qs);
      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();
      

      }

      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls
      import Qt5Compat.GraphicalEffects

      Window {
      visible: true
      color: "#55557f"
      width: 800
      height: 480
      title: qsTr("Hello World")

      CircularProgressBar{
          id:progress1
          x: 49
          y: 79
          value:10
          progressColor:"Blue"
      

      }
      }

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 5 Jul 2022, 05:11 last edited by
      #2

      @Pr0y said in QQmlApplicationEngine failed to load component:

      qrc:/Test_C/main.qml:13:5: CircularProgressBar is not a type

      the error message says it all, your CircularProgressBar is the issue, it's not known at run time.

      Either, you haven't added it to your resource system or there is some other error inside the class file. I can't tell, as you do not show that one


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Pr0y
        wrote on 5 Jul 2022, 05:17 last edited by J.Hilk 7 May 2022, 05:45
        #3

        //this is CircularProgressBar

        import QtQuick
        import QtQuick.Shapes
        import Qt5Compat.GraphicalEffects
        
        Item {
            property int startAngle: -90
            property real maxvalue: 100
            property real value: 30
            property color bgColor: "transparent"
            property color bgStrokeColor: "gray"
            property int strokeBgWidth: 16
            property bool textShowValue: true
            property color progressColor: "Pink"
            property int progressWidth: 16
            property string text: "%"
        
            id:progress
            implicitWidth: 250
            implicitHeight: 250
        
            Shape{
                id:shape
                anchors.fill: parent
                layer.enabled: true
                layer.samples: 12
        
                ShapePath{
                    id:pathBG
                    strokeColor:progress.bgStrokeColor
                    fillColor:progress.bgColor
                    strokeWidth:progress.strokeBgWidth
                    capStyle: ShapePath.RoundCap
                    PathAngleArc{
                        radiusX: 100
                        radiusY: 100
                        centerX: 120
                        centerY: 120
                        startAngle: progress.startAngle
                        sweepAngle: 360
                    }
                }
                ShapePath{
                    id:path
                    strokeColor:progress.progressColor
                    fillColor:"transparent"
                    strokeWidth:progress.strokeBgWidth
                    capStyle: ShapePath.RoundCap
                    PathAngleArc{
                        radiusX: 100
                        radiusY: 100
                        centerX: 120
                        centerY: 120
                        startAngle: progress.startAngle
                        sweepAngle: (360/progress.maxvalue * progress.value)
                    }
                }
                Text{
                    id:textProgress
                    text:progress.textShowValue?parseInt(progress.value) + progress.text:progress.text
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                    color:"Black"
                    font.bold: true
                    font.pointSize: 20
                }
            }
        }
        
        jsulmJ 1 Reply Last reply 5 Jul 2022, 05:18
        0
        • P Pr0y
          5 Jul 2022, 05:17

          //this is CircularProgressBar

          import QtQuick
          import QtQuick.Shapes
          import Qt5Compat.GraphicalEffects
          
          Item {
              property int startAngle: -90
              property real maxvalue: 100
              property real value: 30
              property color bgColor: "transparent"
              property color bgStrokeColor: "gray"
              property int strokeBgWidth: 16
              property bool textShowValue: true
              property color progressColor: "Pink"
              property int progressWidth: 16
              property string text: "%"
          
              id:progress
              implicitWidth: 250
              implicitHeight: 250
          
              Shape{
                  id:shape
                  anchors.fill: parent
                  layer.enabled: true
                  layer.samples: 12
          
                  ShapePath{
                      id:pathBG
                      strokeColor:progress.bgStrokeColor
                      fillColor:progress.bgColor
                      strokeWidth:progress.strokeBgWidth
                      capStyle: ShapePath.RoundCap
                      PathAngleArc{
                          radiusX: 100
                          radiusY: 100
                          centerX: 120
                          centerY: 120
                          startAngle: progress.startAngle
                          sweepAngle: 360
                      }
                  }
                  ShapePath{
                      id:path
                      strokeColor:progress.progressColor
                      fillColor:"transparent"
                      strokeWidth:progress.strokeBgWidth
                      capStyle: ShapePath.RoundCap
                      PathAngleArc{
                          radiusX: 100
                          radiusY: 100
                          centerX: 120
                          centerY: 120
                          startAngle: progress.startAngle
                          sweepAngle: (360/progress.maxvalue * progress.value)
                      }
                  }
                  Text{
                      id:textProgress
                      text:progress.textShowValue?parseInt(progress.value) + progress.text:progress.text
                      anchors.verticalCenter: parent.verticalCenter
                      anchors.horizontalCenter: parent.horizontalCenter
                      color:"Black"
                      font.bold: true
                      font.pointSize: 20
                  }
              }
          }
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 Jul 2022, 05:18 last edited by
          #4

          @Pr0y Please read what @J-Hilk wrote again.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Pr0y
            wrote on 5 Jul 2022, 05:30 last edited by
            #5

            I am very new to this field ,can you guide me...
            On the Design window I can see things are working but when I run those errors I am getting.....
            //this is project file
            QT += quick quickcontrols2

            SOURCES +=
            main.cpp

            resources.files = main.qml
            resources.prefix = /$${TARGET}
            RESOURCES += resources

            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

            DISTFILES +=
            CircularProgressBar.qml

            J 1 Reply Last reply 5 Jul 2022, 05:33
            0
            • P Pr0y
              5 Jul 2022, 05:30

              I am very new to this field ,can you guide me...
              On the Design window I can see things are working but when I run those errors I am getting.....
              //this is project file
              QT += quick quickcontrols2

              SOURCES +=
              main.cpp

              resources.files = main.qml
              resources.prefix = /$${TARGET}
              RESOURCES += resources

              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

              DISTFILES +=
              CircularProgressBar.qml

              J Offline
              J Offline
              J.Hilk
              Moderators
              wrote on 5 Jul 2022, 05:33 last edited by
              #6

              @Pr0y in your project tree, left hand side, if you're using QtCreator, you should see a Resources folder with a qml.qrc file in it. Expand that and tell me/us or screenshot the content. I think your CircularProgressBar is not in there, and thats the reason for your problem


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Pr0y
                wrote on 5 Jul 2022, 05:40 last edited by
                #7

                Image__.PNG
                //after adding a qrc file and then adding CircularProgressBar there This is the view
                snap.PNG
                //Project file is..
                //But still error
                QT += quick quickcontrols2

                SOURCES +=
                main.cpp

                resources.files = main.qml
                resources.prefix = /$${TARGET}
                RESOURCES += resources
                CircularBar.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

                DISTFILES +=

                J 1 Reply Last reply 5 Jul 2022, 05:52
                0
                • P Pr0y
                  5 Jul 2022, 05:40

                  Image__.PNG
                  //after adding a qrc file and then adding CircularProgressBar there This is the view
                  snap.PNG
                  //Project file is..
                  //But still error
                  QT += quick quickcontrols2

                  SOURCES +=
                  main.cpp

                  resources.files = main.qml
                  resources.prefix = /$${TARGET}
                  RESOURCES += resources
                  CircularBar.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

                  DISTFILES +=

                  J Offline
                  J Offline
                  J.Hilk
                  Moderators
                  wrote on 5 Jul 2022, 05:52 last edited by
                  #8

                  @Pr0y

                  well your qml file seems to be fine.

                  f7792959-8c17-4ff5-b835-f43b368fe05d-image.png

                  it has to be the project setup, is the error message the same ?


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Pr0y
                    wrote on 5 Jul 2022, 05:53 last edited by
                    #9

                    It is working ....
                    added the CircularProgressBar in resource file

                    1 Reply Last reply
                    1
                    • P Offline
                      P Offline
                      Pr0y
                      wrote on 5 Jul 2022, 07:16 last edited by
                      #10

                      Thank you all

                      1 Reply Last reply
                      1

                      1/10

                      5 Jul 2022, 04:42

                      • Login

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