Re: Using VSCode with QML
I am not familiar with using CMake inside of VS Code, but I know from building standalone CMake projects that changes to the CMakeLists.txt files sometimes don't get recognized because of CMake's cache. Try deleting your CMake cache and regenerating the project.
Re: Using VSCode with QML
Quote:
Originally Posted by
Zoinen
File in the root folder of my project is actually being generated
In the build dir or in the source dir?
Re: Using VSCode with QML
Quote:
Originally Posted by
Zoinen
Hello. I've always used Qt Creator and was mostly happy with it, but with the recent advent of AI tools in Visual Studio Code (specifically, Cursor IDE that is a fork of VSCode), I decided to give it a try. So, here's the problem: I installed all the latest addons from Qt Company related to Qt, in my CMake project I've added -DQT_QML_GENERATE_QMLLS_INI=ON to enable .qmlls.ini files generation. File in the root folder of my project is actually being generated:
Code:
[General]
buildDir=D:/Code/MyProject/build
no-cmake-calls=false
docDir=C:/Dev/Qt6.8.1/Docs/Qt-6.8.1
importPaths=
I've restarted IDE and QML language server, but any QML files I open don't recognize any QML modules. So, even the first line like
gives
Code:
Warnings occurred while importing module "QtQuick":
Failed to import QtQuick. Are your import paths set up properly? Did you set the "QT_QML_GENERATE_QMLLS_INI" CMake variable on your project to "ON"? qmllint
Output from QML Language Server in VSCode is not useful either. All it says:
Code:
[Warn - 4:16:35 PM] Registration of file updates failed, will miss file changes from outside the editor.-32603 Request client/registerCapability failed with message: No feature implementation for workspace.didChangeWatchedFiles found. Registration failed.
Does anyone have any experience with using QML in VSCode? I couldn't find any decent docs since this tech is relatively new. I'm on Windows. I use Qt 6.8.2 with QML Language Server component installed
Based on similar reports and documentation I found, the key issue seems to be that your .qmlls.ini file’s importPaths field is empty. The QML language server needs to know where to find the Qt QML modules (such as QtQuick). Typically, you need to specify the QML modules directory from your Qt installation—often something like:
importPaths=C:/Dev/Qt6.8.1/qml
Without this path, the language server won’t be able to resolve QML imports, which is why you’re seeing the “Failed to import QtQuick” error.
** Moderator's note: Spam link removed. Last warning - next time, you will be banned. **