QML module Imports Not Found by IDE
-
@GrecKo For me nothing changes when I build it, the warnings remain the exact same. I also tried to do Tools > QML > Reset Codebade but it doesn't help. I could well imagine that this is just a bug in the newest version of Qt Creator or Qt framework, do you have the same environment as me installed?
-
@GrecKo said in QML module Imports Not Found by IDE:
Have you tried? I tried and it clearly does complain.
Sure thing, I am doing that every day. But of course I never try to import a project containing nothing but its own
Main.qml
.
The issue here starts by including something that doesn't need to be included - and therefore shouldn't be.
The warnings disappear in the following cases:- project contains something worth including, e.g. a QML extension written in C++
- unnecessary include statement is removed
The warning says "Failed to import untitled". To me, that's clear: Either there's nothing to import at all, or the import of something existing failed. It could be a suggestion in our bug tracker, to emit separate warnings:
- Nothing to import
- Failed to import (there is something
-
You can have a look at the
FX_Material_Showroom
example to see how import syntax works.
Also look at this Jira ticket for reference. -
@Axel-Spoerl said in QML module Imports Not Found by IDE:
The warning says "Failed to import untitled". To me, that's clear: Either there's nothing to import at all, or the import of something existing failed. It could be a suggestion in our bug tracker, to emit separate warnings:
- Nothing to import
- Failed to import (there is something
The first point is incorrect, the warning is there even when there's something to import (and even used).
And not having something else but Main.qml wouldn't warrant this. The module is there to import. The language server doesn't evaluate if a module is worth importing before importing, it just imports it. As confirmed by Qt Creator initially complaining but not after a build on my system with only Main.qml in the module (note that a clean reintroduces the warning).@SimpleY said in QML module Imports Not Found by IDE:
@GrecKo For me nothing changes when I build it, the warnings remain the exact same. I also tried to do Tools > QML > Reset Codebade but it doesn't help. I could well imagine that this is just a bug in the newest version of Qt Creator or Qt framework, do you have the same environment as me installed?
I am also using Qt C 14.0.2 and Qt 6.8.0 but on Linux with GCC.
I do think this is worthy of a bug report, not sure if it will be high priority though. (EDIT: Axel mentioned this thread in the relevant Jira ticket, it is closed though). -
Hello! From a quick look, it seems that your qmlls is not setup correctly and therefore can't find untitled. Could you try following steps and see if they resolve your issue?
- Pass the build folder to qmlls: you can do this via a variety of options (https://doc.qt.io/qt-6/qtqml-tooling-qmlls.html#setting-up-the-qml-language-server-in-your-editor) but I recommend setting the QT_QML_GENERATE_QMLLS_INI CMake variable to ON.
- Build the project: that generates the qmldir files etc (via the qt_add_qml_module) that qmlls needs to detect QML modules (and the .qmlls.ini files if you set QT_QML_GENERATE_QMLLS_INI to ON in the previous step)
- Restart the language server (using the language server button in the toolbar right above the QML text editor
)
-
@Sami-Shalayel Oh my god thank you so much! This really worked like a charm, now I only get this warning but I am well aware that this is normal now...
All I had to do as you said is addset(QT_QML_GENERATE_QMLLS_INI ON)
in the CMake file and rebuild.So in the future I just have to set
QT_QML_GENERATE_QMLLS_INI
toON
in all of my projects or should I try to fix it another way? -
-
If it works for you then Qt Creator can set it for you automatically on new projects if you check the checkbox at Preferences > Qt Quick > QML/JS Editing > Create .qmlls.ini files for new projects (see also https://doc.qt.io/qtcreator/creator-how-to-use-qml-language-server.html ). Its currently not checked by default because the current solution currently does not satisfy everyone (some people can't have .qmlls.ini files generated in their source folder for example), but there will be a solution to make it work out of the box in qt creator in the future.
-
@Sami-Shalayel Hey, thank you again! That option is quite useful for new projects.
If it's not too much to ask can you please also check out this issue since you seem to be familiar with QMLLS?
-
-
@Sami-Shalayel
hello ! I have been facing the same issue but I am using mac m4 and I tried what you mentioned in the comment. but it does not work.
android architecture arm64v8a
qt creator 6.8.0
qt version same as mentioned in the problem.
using "qmlRegisterType" to link the qt but as the problem says its throw warning and autocompletion is also not working.the same thing properly working in qt 6.7.2 but not in latest version
guide me if you have solution.
-
@SimpleY i ve got same problem as your, try to go to preferences->Qt Quick->QML/JS editing-> QML Language server and remove tick on Tun on (leave all unchecked)
it worked for me.