一、QQmlApplicationEngine failed to load component
- 问题:QQmlApplicationEngine failed to load component报错,报错内容如下:
QML debugging is enabled. Only use this in a safe environment.
QQmlApplicationEngine failed to load component
qrc:/main.qml:-1 No such file or directory
- 解决方法:
将main.cpp中的内容改成如下:
int main(int argc, char *argv[])
{
#if defined(Q_OS_WIN)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// 修改下面的路径
engine.load(QUrl(QStringLiteral("file:../qml_video/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
参考: