# Qt projects

[Qt](https://www.qt.io/) is a cross-platform C++ framework for creating GUI applications. Qt uses its own build system, [qmake](https://wiki.qt.io/Qmake), and also supports [building with CMake](https://doc.qt.io/qt-5/cmake-manual.html) starting from the version Qt4.

A pure Qmake project can't be imported in CLion directly. However, when converted into CMake, it can be opened and managed as a regular [CMake application](quick-cmake-tutorial.html). You can also [create a CMake-based Qt project](#qt-template) in CLion using the New Project wizard.

> **Tip:**
> Another option to open a Qt project is to use a [compilation database](compilation-database.html). You can generate `compile_commands.json` for your qmake project with the help of [scan-build](https://github.com/rizsotto/scan-build) or via the `Build | Generate Compilation Database` action in Qt Creator, then open this file as a project in CLion and add [custom build targets and custom Run/Debug configurations](custom-build-targets.html) for it.

## CMake-based Qt projects

For CMake version 3.0 and newer, Qt ships the modules that let CMake find and use Qt4 and Qt5 libraries. Take the following steps to configure [CMakeLists.txt](cmakelists-txt-file.html) for your Qt project.

Procedure: CMakeLists.txt for a Qt project

1. Add the `find_package` command to locate the required libraries and header files. For example:

```CMAKE
find_package(Qt5Widgets REQUIRED)
```

Then, use `target_link_libraries` to make your target dependent on these libraries and headers:

```CMAKE
target_link_libraries(helloworld Qt5::Widgets)
```

2. For `find_package` to perform successfully, CMake should be instructed on where to find the Qt installation.

One of the ways to do this is by setting the `CMAKE_PREFIX_PATH` variable. You can either pass it via `-D` in the [CMake settings](#cmake-settings) dialog or via the `set` command before `find_package`.

For example, in the case of MinGW on Windows:

```CMAKE
set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.14.0\\5.14.0\\mingw73_32\\")
```

or

```CMAKE
set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.14.0\\5.14.0\\mingw73_32\\lib\\cmake\\")
```

3. If your project uses [MOC](https://doc.qt.io/archives/qt-4.8/moc.html), [UIC](https://doc.qt.io/archives/qt-4.8/uic.html), or [RCC](https://doc.qt.io/qt-5/rcc.html), add the following lines to enable automatic invocation of the corresponding compilers:

```CMAKE
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
```

4. List all the `.ui` and `.qrc` files in the `add_executable()` command along with your `.cpp` sources:

```CMAKE
add_executable(
    helloworld
    main.cpp mainwindow.cpp
    application.qrc
)
```

Below you can find the full `CMakeLists.txt` script for a simple "Hello, world" application:

```CMAKE
cmake_minimum_required(VERSION 3.10)
project(Qt-CMake-HelloWorld)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.14.0\\5.14.0\\mingw73_32\\")

find_package(Qt5Widgets REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

add_executable(helloworld main.cpp mainwindow.cpp application.qrc)
target_link_libraries(helloworld Qt5::Widgets)
```

## Setting up a Qt project in CLion

Procedure: Toolchains on Windows

1. When installing Qt on Windows, pick the distributive that matches the environment you are using in CLion, MinGW or MSVC.

For MinGW, both the version and the bitness (32-bit MinGW or MinGW-w64) should match with your toolchain setup.

![Qt installer](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_installer.png)

2. In CLion, go to `Settings`(`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))), navigate to `Build, Execution, Deployment | Toolchain` and select the toolchain that matches your Qt installation.

If you have several Qt installations, make sure to select the same toolchain as the one you [specified](#configure-cmakelists) in `CMAKE_PREFIX_PATH`.

As an example, in the case of MinGW:

![MinGW toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_mingw_toolchain.png)

> **Tip:**
> For more information about Windows toolchains, refer to the [MinGW](quick-tutorial-on-configuring-clion-on-windows.html#MinGW) or [MSVC](quick-tutorial-on-configuring-clion-on-windows.html#MSVC) section of our Windows Tutorial.

Procedure: CMake settings

* Qt projects are handled as regular CMake projects in CLion, so you can configure CMake settings in `Settings | Build, Execution, Deployment | CMake` as necessary.

For example, you can create different CMake profiles with different [build types](cmake-profile.html#buildtypes) and set up CMake [generators](cmake-profile.html#cmake-generators) of your choice.

In this dialog, you can also specify CMake options, such as `CMAKE_PREFIX_PATH` instead of setting them in `CMakeLists.txt`:

![CMake options for a Qt project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_cmake_options.png)

Procedure: Debugger renderers

Depending on the platform and the toolchain you use, CLion offers different types of debugger renderers for Qt projects.

On Windows MinGW, macOS, and Linux, the IDE provides Qt debugger renderers, also known as Qt pretty printers and Qt debugging helpers. They allow you to view Qt types, such as `QString` or `QByteArray`, in a human-readable form.

If you use [Windows with the MSVC toolchain](quick-tutorial-on-configuring-clion-on-windows.html#msvc-debugger), the IDE provides Natvis renderers, which use the native visualizer format from Visual Studio.

Both renderer types are enabled by default in CLion. You can disable them in `Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++ | Renderers`.

> **Note:**
> Qt renderers don’t yet work with remote and WSL toolchains.

Procedure: Open UI files in Qt Designer

By default, CLion opens `.ui` files in [Qt Designer](https://doc.qt.io/qt-5/qtdesigner-manual.html).

The IDE searches for the path to Qt Designer in the `Qt binaries` folder specified in `Settings | Languages & Frameworks | QML`.

If you installed Qt Designer separately from Qt, CLion might not detect it and will open the `.ui` files in the editor. In this case, do the following to open them in Qt Designer:

1. Go to `Settings | Editor | File Types`.

2. Select Qt UI Designer Form from the Recognized File Types list, and delete the associated file extension:

![Removing the association for .ui files](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_ui_removeassoc.png)

3. Select Files opened in associated applications and add the `.ui` extension:

![Reassign .ui to external application](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_ui_externalapp.png)

4. Cick Reassign Wildcard.

5. Click Apply and close the dialog.

Next time you double-click a `.ui` file in the Project tree, it will be opened in Qt Designer.

## Creating a CMake-based Qt project

CLion provides two project templates for Qt: Qt Console Executable and Qt Widgets Executable.

Call `File | New Project` and select the project type in the left-hand pane. Specify the location, language standard, and Qt version. You can also provide the path to be used in `CMAKE_PREFIX_PATH`. Click Create when ready.

![Qt project templates](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_projectwizard.png)

CLion will generate a ready-to-go stub project with `CMakeLists.txt` filled in automatically, including the `CMAKE_PREFIX_PATH` variable:

![Qt Console Executable template project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_consoleexe_addprefixpath.png)

> **Tip:**
> You can edit the `CMakeLists.txt` template for Qt projects in `Settings | Editor | File and Code Templates`, the Other tab. For more information, refer to [CMakeLists.txt file templates](cmakelists-txt-file.html#cmakelist-template).

## Qt UI class templates

You can quickly create a Qt class with the corresponding `.ui`, `.cpp`, and `.h` files.

Procedure:

1. In the Project view, select New from the context menu or press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌥ Insert` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)). Choose Qt UI Class:

![New Qt UI Class menu option](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_new_uiclass.png)

2. In the dialog that opens, fill in the class name and configure the following settings:

* Filename base - specify the name for the `.ui`/`.cpp`/`.h` files to be generated.

* Parent class - select `QWidget`, `QMainWindow`, `QDialog`, or a custom parent class.

* Namespace - specify the enclosing namespace if required.

* Add to targets - set this checkbox to automatically add the new files to the list of sources for the selected target(s).

![New Qt UI Class dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_new_uiclass_dialog.png)

3. CLion will generate the `.ui`, `.cpp`, and `.h` files following the [templates](using-file-and-code-templates.html) defined in `Settings | Editor | File and Code Templates`: Qt Designer Form, Qt Class, and Qt Class Header, respectively. If required, you can adjust these templates for your needs.

![Files generated for a new Qt UI class](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_ui_generated.png)

## Qt-specific code insight

* CLion provides [code completion](auto-completing-code.html) for [Qt signals and slots](https://doc.qt.io/qt-5/signalsandslots.html), filtering the suggestion list to show only the corresponding members: ![Completion for Qt signals](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_completion_signals.png) Completion works for the `SIGNAL()` and `SLOT()` macros as well: ![Completion for the SLOT macro](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_completion_slots.png)

* CLion's auto-import supports Qt-style header files, offering the shortest possible `#include`: ![Qt-style auto-import](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_import.png)

## QtCreator keymap

CLion bundles the [QtCreator keymap](https://doc.qt.io/qtcreator/creator-keyboard-shortcuts.html). You can switch to it in `Settings | Keymap` or by calling `View | Quick Switch Scheme` from the main menu (`Ctrl+`` (Windows), `⌃ `` (macOS), `⌃ `` (IntelliJ IDEA Classic (macOS)), `⌃ `` (macOS System Shortcuts), `Ctrl+`` (XWin), `Ctrl+`` (GNOME), `Ctrl+`` (KDE), `Ctrl+`` (Emacs), `Ctrl+`` (Sublime Text), `⌃ `` (Sublime Text (macOS)), `⌃ `` (Xcode), `Ctrl+`` (Visual Studio), `Ctrl+`` (Visual Studio (macOS)), `Ctrl+`` (ReSharper), `Ctrl+`` (ReSharper (macOS)), `Ctrl+`` (QtCreator), `⌃ `` (QtCreator (macOS)), `Ctrl+`` (NetBeans), `Ctrl+`` (Eclipse), `⌃ `` (Eclipse (macOS))):

![Switching to the Qt keymap](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_switch_keymap.png)

## Current limitations

* Two umbrella tickets in CLion tracker: [Qt project support (CPP-318)](https://youtrack.jetbrains.com/issue/CPP-318) and [Qt issues (CPP-1897)](https://youtrack.jetbrains.com/issue/CPP-1897).

* Some of the CLion's code generation features may not work for Qt macros, such as `Q_PROPERTY`, `Q_SIGNAL`, `Q_SLOT`, and others.

## Troubleshooting

If you get the Process finished with exit code -1073741515 (0xC0000135) error message when running on MinGW, the issue might relate to [Qt deployment on Windows](https://doc.qt.io/qt-5/windows-deployment.html): dynamic libraries and Qt plugins must be found from the directory of the running binary. Try one of the workarounds described below.

Procedure: Option 1

1. Add the path to `bin` under the MinGW directory in the Qt installation (for example, `C:\Qt\5.15.1\mingw81_64\bin`) to the system `PATH` or in the Environment variables field of the configuration settings.

If this doesn't solve the issue for your project, try Option 2.

Procedure: Option 2

1. Copy the `.dll`-s located in `bin` under the MinGW directory in the Qt installation to your project’s generation folder, which is `cmake-build-debug` or `cmake-build-release` by default.

The libraries you will most likely need are `libstdc++-6.dll`, `Qt5Widgets.dll`, `Qt5Gui.dll`, and `Qt5Core.dll`, but your setup might require other libraries as well.

2. In the settings of the configuration you use for running, set the `QT_QPA_PLATFORM_PLUGIN_PATH` environment variable to `plugins\platforms` under the MinGW directory:

![Environment variable for the Qt plugins path](https://resources.jetbrains.com/help/img/idea/2026.2/cl_qt_envvar_plugins_config.png)

> **Tip:**
> Another option is to copy the contents of `plugins\platforms` to `cmake-build-debug(release)/platforms` (make sure to create the `platforms` directory).

For more information, refer to [Qt Plugins](https://doc.qt.io/qt-5/windows-deployment.html#qt-plugins).

## See also

### Getting Started

[Quick CMake tutorial](quick-cmake-tutorial.html) [Quick Tutorial on Configuring CLion on Windows](quick-tutorial-on-configuring-clion-on-windows.html)

