Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QQmlApplicationEngine failed to load component

QQmlApplicationEngine failed to load component

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 204 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HenrikZ
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      HenrikZ
      wrote on last edited by
      #4

      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.

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #2

        Wayland or X11 on your embedded Linux system?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          HenrikZ
          wrote on last edited by
          #3

          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.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HenrikZ
            wrote on last edited by
            #4

            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.

            1 Reply Last reply
            0
            • H HenrikZ has marked this topic as solved on
            • H HenrikZ has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved