Error Loading QML Custom Component from Separate File with Qt 5.15 in Visual Studio
-
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!
-
Hello,
please provide a minimal compilable reproducer.
Looks to me as if the reference to the resource file inToolBar.qml:46:23
is wrong. -
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. -
@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.