Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Error Loading QML Custom Component from Separate File with Qt 5.15 in Visual Studio
Forum Updated to NodeBB v4.3 + New Features

Error Loading QML Custom Component from Separate File with Qt 5.15 in Visual Studio

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 403 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Rufledore
    wrote on last edited by
    #1

    Hello,

    I'm working on integrating a QML toolbar with icons into our Qt Widget application. The setup involves using QQuickWidget to bridge between the widget's layout and the QML content. My project includes two QML files: ToolBar.qml and Icon.qml, where ToolBar.qml utilizes the Icon component.

    Our main application is developed in Visual Studio, and we manually run tools like moc.exe, uic.exe, and rcc.exe. We're using prebuilt Qt 5.15.2. To streamline QML development and debugging, I created a separate QML runner project in Qt Creator (using CMake), which employs the same .qrc file and QML files. This setup works perfectly in the runner project.

    However, when I attempt to integrate the ToolBar into the main application, it throws a runtime error:

    file::res/qml/ToolBar.qml:46:23: Icon is not a type
    

    Interestingly, if I inline the Icon content directly within ToolBar.qml, everything functions correctly. This leads me to believe there's an issue with how the QML files reference each other, despite both being in the same folder and included in the .qrc file.

    Has anyone else encountered this issue? I suspect it might be related to a missing build flag or a specific procedure in the build process that I'm overlooking.

    I didn't include the QML content as it seems unrelated directly to the issue, but I can provide simplified versions of the files if it helps.

    Thank you for any insights or suggestions you might have!

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      Hello,
      please provide a minimal compilable reproducer.
      Looks to me as if the reference to the resource file in ToolBar.qml:46:23 is wrong.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rufledore
        wrote on last edited by
        #3

        Hello, thank you for the response! ToolBar.qml works okay if Icon is declared as a component, but it returns this error if Icon is from a file Icon.qml. So, it seems it's a file reference problem. And it only appears if I build with Visual Studio.
        I will provide a simple code example as soon as I can.

        Axel SpoerlA 1 Reply Last reply
        0
        • R Rufledore

          Hello, thank you for the response! ToolBar.qml works okay if Icon is declared as a component, but it returns this error if Icon is from a file Icon.qml. So, it seems it's a file reference problem. And it only appears if I build with Visual Studio.
          I will provide a simple code example as soon as I can.

          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          @Rufledore said in Error Loading QML Custom Component from Separate File with Qt 5.15 in Visual Studio:

          And it only appears if I build with Visual Studio.

          In that case the issue is in the local build system.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0

          • Login

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