Quantcast
Viewing latest article 10
Browse Latest Browse All 137

Qt/QML issue: when launching cannot find main.qml file

My C++/QML app compiles, but at launch I get this error:

00:51:26: Starting /home/pietro/QtQuickTest/build/Desktop_latest-Debug/appQtQuickTest...QML debugging is enabled. Only use this in a safe environment.QQmlApplicationEngine failed to load componentqrc:/qt/qml/main.qml: No such file or directory

The /qt/qml/main.qml path should be correct, since I am using Qt 6.6.The original main.qml file is in the project root directory ., and a copy is made during the build in ./build/Desktop_latest-Debug/appQtQuickTest/.

In the main.cpp file there is the line:

engine.load(QUrl(QStringLiteral("qrc:/qt/qml/main.qml")));

I also tried with the old style approach, resulting in the same error:

engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

I checked all over the project, and there are no upper/lowercase issues.

This is the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.16)project(QtQuickTest VERSION 0.1 LANGUAGES CXX)set(CMAKE_CXX_STANDARD_REQUIRED ON)find_package(Qt6 6.6 COMPONENTS Quick Gui REQUIRED)qt_standard_project_setup(REQUIRES 6.6)set(CMAKE_CXX_STANDARD 17)set(CMAKE_CXX_STANDARD_REQUIRED ON)qt_add_executable(appQtQuickTest    main.cpp    TreeItem.h    TreeItem.cpp    TreeModel.h    TreeModel.cpp)qt_add_qml_module(appQtQuickTest    URI QtQuickTest    VERSION 1.0    QML_FILES        main.qml    RESOURCES        Description.md        test.json)target_link_libraries(appQtQuickTest    PRIVATE Qt6::Gui Qt6::Quick)

The following QRC file is produced by the build system: QtQuickTest/build/Desktop_latest-Debug/.rcc/appQtQuickTest_raw_qml_0.qrc:

<RCC><qresource prefix="/qt/qml/QtQuickTest/"><file alias="main.qml">/home/pietro/QtQuickTest/main.qml</file><file alias="test.json">/home/pietro/QtQuickTest/test.json</file></qresource></RCC>

What am I doing wrong?


Viewing latest article 10
Browse Latest Browse All 137

Trending Articles