QQmlApplicationEngine failed to load component
-
The QtQuick program runs without problems on the desktop, but when I compile for an embedded linux system and afterwards try to run the program on the MCU i get the error, but the error first occurs when the program is executed in the embedded linux. There is not issues or messages during compilation. In the command prompt I get the following error.
QQmlApplicationEngine failed to load component
<Unknown File>: Module "GPIO_InputTest2" contains no type named "Main"This could indicate that the "Main.qml" were not correctly included - The CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.16) project(GPIO_InputTest2 VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(appGPIO_InputTest2 main.cpp VirtualInputReader.cpp VirtualInputReader.h ) qt_add_qml_module(appGPIO_InputTest2 URI GPIO_InputTest2 VERSION 1.0 QML_FILES "Main.qml" SOURCES VirtualInputReader.h VirtualInputReader.cpp RESOURCE_PREFIX / ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. set_target_properties(appGPIO_InputTest2 PROPERTIES # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appGPIO_InputTest2 MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) target_link_libraries(appGPIO_InputTest2 PRIVATE Qt6::Quick ) include(GNUInstallDirs) install(TARGETS appGPIO_InputTest2 BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
Both main.cpp and Main.qml are added.
Any suggestions where the problem is?
-
Issue solved
It turned out to be a single line missing in main.cpp
engine.addImportPath(":/");
Exactly why this line is needed, when the program is running on an embedded linux and not on the desktop, I am not sure, but I guess that ":/" tells the program to find the Main.qml in the same root folder as program is running from.
-
Hi @JoeCFD
Wayland for the embedded linux system.
I have made other small test applications that works without problems, but this one, where I'm testing inputs does not work, and I cannot see the difference from the other the applications I have made and this one.
-
Issue solved
It turned out to be a single line missing in main.cpp
engine.addImportPath(":/");
Exactly why this line is needed, when the program is running on an embedded linux and not on the desktop, I am not sure, but I guess that ":/" tells the program to find the Main.qml in the same root folder as program is running from.
-
-