QQmlApplicationEngine failed to load component
-
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.GraphicalEffectsWindow {
visible: true
color: "#55557f"
width: 800
height: 480
title: qsTr("Hello World")CircularProgressBar{ id:progress1 x: 49 y: 79 value:10 progressColor:"Blue"
}
} -
@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
-
//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 } } }
-
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 quickcontrols2SOURCES +=
main.cppresources.files = main.qml
resources.prefix = /$${TARGET}
RESOURCES += resourcesAdditional 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 += targetDISTFILES +=
CircularProgressBar.qml -
@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
-
//after adding a qrc file and then adding CircularProgressBar there This is the view
//Project file is..
//But still error
QT += quick quickcontrols2SOURCES +=
main.cppresources.files = main.qml
resources.prefix = /$${TARGET}
RESOURCES += resources
CircularBar.qrcAdditional 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 += targetDISTFILES +=