Ambiguous project when using files in subdirectory
-
I'm trying to keep my files in separate subdirectories so that things are more organized and easier to manage than when dumping everything in the root directory.
The resources and sources work fine, but I'm having a lot of problems getting QML to work properly with this approach.
When the files are in the root directory the project runs fine:
qt_add_qml_module(appMyProject URI MyProject VERSION 1.0 QML_FILES Main.qml PlanetList.qml NumberFormatter.js )
but when I try to use them in subdirectories, things no longer work
qt_add_qml_module(appMyProject URI MyProject VERSION 1.0 QML_FILES Main.qml src/qml/PlanetList.qml src/qml/NumberFormatter.js
The error I get is:
warning: qrc:/qt/qml/MyProject/src/qml/PlanetList.qml: "MyProject" is ambiguous. Found in qrc:/qt/qml/MyProject/ and in qrc:/qt/qml/MyProject/I'm not sure what's going on as according to this message it seems it can't tell the difference between itself and itself.
How can I troubleshoot this or get it to work properly?
Thanks
-
I'm trying to keep my files in separate subdirectories so that things are more organized and easier to manage than when dumping everything in the root directory.
The resources and sources work fine, but I'm having a lot of problems getting QML to work properly with this approach.
When the files are in the root directory the project runs fine:
qt_add_qml_module(appMyProject URI MyProject VERSION 1.0 QML_FILES Main.qml PlanetList.qml NumberFormatter.js )
but when I try to use them in subdirectories, things no longer work
qt_add_qml_module(appMyProject URI MyProject VERSION 1.0 QML_FILES Main.qml src/qml/PlanetList.qml src/qml/NumberFormatter.js
The error I get is:
warning: qrc:/qt/qml/MyProject/src/qml/PlanetList.qml: "MyProject" is ambiguous. Found in qrc:/qt/qml/MyProject/ and in qrc:/qt/qml/MyProject/I'm not sure what's going on as according to this message it seems it can't tell the difference between itself and itself.
How can I troubleshoot this or get it to work properly?
Thanks
Hi, and welcome!
@DoktorNik said in Ambiguous project when using files in subdirectory:
How can I troubleshoot this or get it to work properly?
You might be encountering one of these bugs:
Upgrade to Qt 6.10.0-beta2. Does it work now?
-
Hi, and welcome!
@DoktorNik said in Ambiguous project when using files in subdirectory:
How can I troubleshoot this or get it to work properly?
You might be encountering one of these bugs:
Upgrade to Qt 6.10.0-beta2. Does it work now?
@JKSH Thanks for the reply and pointing out those bug reports. I verified that the problem has to do with the .js files
I'm still pretty new to Qt so maybe I'm missing something simple, but I couldn't get the beta version to build on my MacBook.
The readme says:
Linux, Mac: ----------- cd <path>/<source_package> ./configure -prefix $PWD/qtbase cmake --build .
but it fails being unable to find something
./configure -prefix $PWD/qtbase + /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase CMake Error at cmake/QtIRProcessHelpers.cmake:173 (message): /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase exited with status: no such file or directory Call Stack (most recent call first): cmake/QtTopLevelHelpers.cmake:35 (qt_ir_execute_process_and_log_and_handle_error) cmake/QtTopLevelHelpers.cmake:57 (qt_tl_run_toplevel_configure) cmake/QtTopLevelConfigureScript.cmake:16 (qt_tl_run_main_script)
Any further advice?
-
@JKSH Thanks for the reply and pointing out those bug reports. I verified that the problem has to do with the .js files
I'm still pretty new to Qt so maybe I'm missing something simple, but I couldn't get the beta version to build on my MacBook.
The readme says:
Linux, Mac: ----------- cd <path>/<source_package> ./configure -prefix $PWD/qtbase cmake --build .
but it fails being unable to find something
./configure -prefix $PWD/qtbase + /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase CMake Error at cmake/QtIRProcessHelpers.cmake:173 (message): /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase exited with status: no such file or directory Call Stack (most recent call first): cmake/QtTopLevelHelpers.cmake:35 (qt_ir_execute_process_and_log_and_handle_error) cmake/QtTopLevelHelpers.cmake:57 (qt_tl_run_toplevel_configure) cmake/QtTopLevelConfigureScript.cmake:16 (qt_tl_run_main_script)
Any further advice?
@DoktorNik You're welcome! I suggest installing the beta using the Qt Online Installer (which becomes the MaintenanceTool after you've run the installer). No need to build it from source
-
@DoktorNik You're welcome! I suggest installing the beta using the Qt Online Installer (which becomes the MaintenanceTool after you've run the installer). No need to build it from source
@JKSH I installed the 6.10.0-beta2 version with the installer/maintenance tool.
Then I cleared the cmake config, removed the build directory, reran cmake, and rebuilt.
Unfortunately, it is the same problem. So long as the .js file is under QML_FILES in qt_add_qml_module, the app doesn't run.
-
It seems to run properly when I include this line in my cmake file:
# workaround for bug with javascript files qt_policy(SET QTP0004 OLD)
Thanks for pointing me in the right direction
@DoktorNik Thanks for sharing your workaround. I'm glad to hear that you got it working.
Thanks also for writing up a detailed bug report: https://bugreports.qt.io/browse/QTBUG-139233 It looks like the "Fix Version(s)" field for QTBUG-138391 was incorrect, and Qt 6.10.0-beta2 still contains the bug. You should be able to remove your workaround once Qt 6.9.2 or 6.10.0 are released.