Results 1 to 4 of 4

Thread: Using VSCode with QML

  1. #1
    Join Date
    Oct 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Using VSCode with QML

    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:
    Qt Code:
    1. [General]
    2. buildDir=D:/Code/MyProject/build
    3. no-cmake-calls=false
    4. docDir=C:/Dev/Qt6.8.1/Docs/Qt-6.8.1
    5. importPaths=
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. import QtQuick
    To copy to clipboard, switch view to plain text mode 
    gives
    Qt Code:
    1. Warnings occurred while importing module "QtQuick":
    2. 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
    To copy to clipboard, switch view to plain text mode 

    Output from QML Language Server in VSCode is not useful either. All it says:
    Qt Code:
    1. [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.
    To copy to clipboard, switch view to plain text mode 


    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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,304
    Thanks
    313
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,366
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using VSCode with QML

    Quote Originally Posted by Zoinen View Post
    File in the root folder of my project is actually being generated
    In the build dir or in the source dir?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2025
    Posts
    1
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Using VSCode with QML

    Quote Originally Posted by Zoinen View Post
    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:
    Qt Code:
    1. [General]
    2. buildDir=D:/Code/MyProject/build
    3. no-cmake-calls=false
    4. docDir=C:/Dev/Qt6.8.1/Docs/Qt-6.8.1
    5. importPaths=
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. import QtQuick
    To copy to clipboard, switch view to plain text mode 
    gives
    Qt Code:
    1. Warnings occurred while importing module "QtQuick":
    2. 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
    To copy to clipboard, switch view to plain text mode 

    Output from QML Language Server in VSCode is not useful either. All it says:
    Qt Code:
    1. [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.
    To copy to clipboard, switch view to plain text mode 


    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. **
    Last edited by d_stranz; 9th March 2025 at 16:33. Reason: removed URL

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.