CLion 2024.2 Help

QML syntax support

CLion provides syntax support in .qml files for both Qt5 and Qt6. Find below a few examples of QML code insight features.

  • Highlighting and code completion for QML types and properties:

    QML completion
  • Find Usages for QML symbols can be invoked by pressing Alt+F7 or clicking the hint in the editor:

    QML symbols usage hints

    In the usages popup you can navigate between them and tune the search ():

    QML symbols usage popup
  • Another navigation option is Structure View for the file contents. To open it, press Alt+7 or select View | Tool Windows | Structure from the main menu:

    QML file structure
  • Quick Documentation popup is also available for QML symbols. Invoke it by hovering over a symbol or by pressing Ctrl+Q:

    Quick documentation for QML symbols

Enable QML language server

  1. Go to Settings | Languages & Frameworks | QML and set the Enable QML language server checkbox.

    Enabling QML languafe server

    This option enables QML-specific code inspections if there are qmlls components installed.

  2. Enable Use completion from QML language server to get language-server-based completion suggestions for QML symbols instead of those provided by CLion.

Add extra QML import paths

  1. Go to Settings | Languages & Frameworks | QML.

  2. In the Extra QML imports field, provide the path to the directory containing additional QML modules.

QML code style

You can use the IDE settings or qmlformat to configure code style for QML.

  • By default, qmlformat is disabled and CLion uses the built-in code style settings. To access them, go to Settings | Editor | Code Style | QML:

    Code style settings for QML

    To quickly access the settings, select Configure Indents for qml QML in the bottom status bar switcher:

    Configure QML code style options
  • To enable qmlformat, use the status bar switcher (see above) or go to Settings | Languages & Frameworks | QML and set the Enable 'qmlformat' as formatter checkbox.

    Enabling qmlformat

    When qmlformat is enabled, its indicator is shown in the bottom status bar. You can also disable qmlformat from there:

    Qmlformat indicator in the status bar

Troubleshooting: enable QML syntax support manually

Follow the steps below if you get the editor notification indicating that CLion could not find the Qt installation path or QML imports directory:

QML imports directory not found warning
  1. Check that CMAKE_PREFIX_PATH points to the Qt installation directory.

    Click CMake settings and add the following to CMake options:

    -DCMAKE_PREFIX_PATH=your_qt_installation

    For example:

    Qt installation path in CMake options
  2. In most cases, configuring CMake is enough for CLion to detect Qt and QML paths, however, if the notification is still there, you might need to set the paths manually. Click QML settings or go to Settings | Languages & Frameworks | QML to do so.

Known issues and limitations

QML support is CLion is currently a work in progress. The list of known issues include:

  • Many standard functions and methods are highlighted as unresolved (CPP-31883).

  • Structure View for QML files is being improved (CPP-31886).

  • QML color scheme and code style settings are in development (CPP-30547).

Last modified: 14 August 2024