Qt qml在开发板上报错QQmlApplicationEngine failed to load component

文章目录

  • 一、QQmlApplicationEngine failed to load component


一、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();
}

参考:

  1. linux qt qrc文件中 xxx.png图片无法加载的问题

你可能感兴趣的:(Linux,Qt,qt,开发语言)