Nova Flow OS
KDE Developer Platform
KDE Developer Platform
  • KDE Developer Platform
    • Getting started
      • Building KDE software
        • KDE software
        • Where to find the development team
        • Learning more
        • Choose what to work on
        • Source code cross-referencing
        • Installing build dependencies
        • Set up a development environment
        • Building KDE software with kdesrc-build
        • Basic troubleshooting
        • Tips and tricks
        • IDE Configuration
          • Setting up an IDE for KDE development
          • Visual Studio Code
          • Qt Creator
          • Kate
          • KDevelop
          • CLion
          • Sublime Text
        • Building KDE software manually
        • Building KDE software with distrobox and podman
      • Kirigami
        • KDE is ours
        • Setting up and getting started
        • Explaining pages
        • Layouts, ListViews, and Cards
        • Adding actions
        • Adding a dialog
        • Using separate files
        • Next steps
        • Colors and themes in Kirigami
        • Typography
        • Actions based components
        • Page rows and page stacks
        • Scrollable pages and list views
        • Cards
        • Drawers
        • Chips
        • Dialog types
        • Controls and interactive elements
        • Form layouts
        • Inline messages
        • Action toolbars
        • Progress bars and indicators
        • List views
        • Understanding CMakeLists
        • Figuring out main.cpp
        • Connect logic to your QML user interface
        • Connect models to your QML user interface
        • About page
        • Introduction to Kirigami Addons
        • FormCard About pages
        • Form delegates in your settings pages
      • KXmlGui
        • Getting started with KXmlGui
        • Hello World!
        • Creating the main window
        • Using actions
        • Saving and loading
        • Command line interface
      • Python with Kirigami
        • Apps with QML and Python
        • Your first Python + Kirigami application
        • Creating a Python package
        • Creating a Flatpak
      • Common programming mistakes
      • Adding a new KDE project
    • Features
      • Icons
      • Configuration
        • The KConfig Framework
        • Introduction to KConfig
        • Using KConfig XT
        • KDE Frameworks 6 porting guide
        • Settings module (KCM) development
        • KConfigDialog
      • D-Bus
        • What is D-Bus practically useful for?
        • Introduction to D-Bus
        • Accessing D-Bus interfaces
        • Intermediate D-Bus
        • Creating D-Bus interfaces
        • Using custom types with D-Bus
        • D-Bus autostart services
      • Create your own mouse cursor theme
      • Session management
      • Archives
      • Desktop file
      • KAuth
        • Privilege Escalation
        • Using actions in your applications
      • KIdleTime
      • Akonadi: personal information management
        • Debugging Akonadi Resources
        • Using Akonadi in applications
      • Concurrent programming
      • Solid
      • Sonnet
    • Plasma themes and plugins
      • Getting started
      • Plasma Widget tutorial
        • How to create a plasmoid
        • Setup
        • Porting Plasmoids to KF6
        • Testing
        • QML
        • Plasma's QML API
        • Widget Properties
        • Configuration
        • Translations / i18n
        • Examples
        • C++ API
      • KWin Effects
      • Plasma Desktop scripting
        • Javascript Interaction With Plasma Shells
        • Templates
        • Examples
        • API documentation
        • Configuration keys
      • Plasma Style tutorial
        • Creating a Plasma Style quickstart
        • Understanding Plasma Styles
        • SVG elements and Inkscape
        • Background SVG format
        • System and accent colors
        • Theme elements reference
        • Porting themes to Plasma 5
        • Porting themes to Plasma 6
      • Aurorae window decorations
      • KWin scripting tutorial
        • Quick start
        • KWin scripting API
      • Wallpapers
      • Plasma comic
        • Tutorial
        • Testing and debugging
        • Examples
      • Create a custom Window Switcher
      • KRunner C++ Plugin
        • Basic Anatomy of a Runner
        • KRunner metadata format
    • Applications
      • Creating sensor faces
      • Dolphin
        • Creating Dolphin service menus
      • Kate
        • Kate plugin tutorial
      • KMines
        • Making a KMines theme
      • Writing tests
        • Appium automation testing
    • Packaging
      • Android
        • KDE on Android
        • Building applications for Android
        • Packaging and publishing applications for Android
        • Publishing on Google Play
          • Introduction
          • Packaging your app
          • Adding your app to Google Play
          • Publishing your app
          • Releasing new versions of old apps
        • Porting applications to Android
          • Basic porting
          • Making applications run well on Android
          • Metadata
      • Windows
        • Packaging and publishing applications for Windows
        • Publish your app in the Microsoft Store
          • Packaging your app for the Microsoft Store
          • Submitting your app to the Microsoft Store
      • Plasma Mobile
        • KDE on mobile devices
        • Porting a new device to Plasma Mobile
        • KDE Telephony stack
          • General Overview
          • Kernel layer
          • System daemons
            • General overview
            • Developing Telephony functionality
            • ModemManager Telephony functions
          • Session daemons
          • QML declarative plugin layer
          • KDE application layer
        • Execute applications
      • Distributing KDE software as Flatpak
        • Your first Flatpak
        • Extending your package
        • Nightly Flatpaks and Flathub
        • Testing your Flatpak
    • System administration
      • Shell scripting with KDE dialogs
      • Kiosk: Simple configuration management for large deployment
        • Abstract
        • Introduction to Kiosk
        • Kiosk keys
    • Contribute to the documentation
    • About
      • Readme
      • License
        • Creative Commons Attribution-ShareAlike 4.0 International
        • GNU General Public License 3.0 or later
Powered by GitBook
On this page
  • Install Qt Creator
  • KDE Builder configuration
  • Applying project configuration in Qt Creator
  • Start developing
  • Tips and Tricks
  1. KDE Developer Platform
  2. Getting started
  3. Building KDE software
  4. IDE Configuration

Qt Creator

Supports many KDE project technologies including Qt, QML, C++, and CMake.

PreviousVisual Studio CodeNextKate

Last updated 8 months ago

is a cross-platform C++, JavaScript, Python and QML IDE.

This article will show you how to configure and develop KDE projects in Qt Creator. We will use KCalc as an example project.

Install Qt Creator

Alternative methods of installation

If you want to use a more recent version of Qt Creator than your distribution provides, you can install Qt Creator as a component in the "Qt online installer". Go to https://www.qt.io/download-dev to download the installer. Make it executable and run it:

chmod +x qt-unified-linux-x64-4.6.1-online.run
./qt-unified-linux-x64-4.6.1-online.run

Note that the Qt online installer requires you to register an account.

Also, you can .

Note

This article assumes you use KDE Builder. The older tool kdesrc-build does not support Qt Creator configuration generation.

KDE Builder configuration

To allow kde-builder to generate Qt Creator project files, add the following to your ~/.config/kdesrc-buildrc:

global
  # other options
  generate-qtcreator-project-config true
end global

Instead of enabling the generate-qtcreator-project-config option globally, you may choose to enable it only for a single project:

options kcalc
  generate-qtcreator-project-config true
end options

Ensure you have successfully built kcalc following the kde-builder instructions.

In case you enabled generate-qtcreator-project-config after you have built kcalc previously, or do not want to edit your config, you can generate CLion configs by running:

kde-builder kcalc --no-include-dependencies --no-src --build-system-only --generate-qtcreator-project-config

Applying project configuration in Qt Creator

Opening project

From the Qt Creator main menu, select File | Open File or Project or press Ctrl + Shift + O and select the ~/kde/src/kcalc/CMakeLists.txt file.

Note

In case you want to start configuration from scratch, just delete the generated CMakeLists.txt.user file and reopen a project.

Selecting Kit

If you are opening the project for the first time, the "Configure Project" view will be opened.

{{< figure width="80%" src="configure_project_view.png)

Press the "Select all kits" checkbox several times to deselect every kit. Then create "KDE Builder kit" (if not done yet), and select it.

Temporary kits

If the project has a CMakePresets.json in its root directory (KCalc does), you will see many temporary kits created for the project. You do not need them, and need to deselect all of them.

For your convenience, you can remove all temporary kits from the project, so they are not shown in the available kits in the Project mode. You can do this in "Manage Kits". In case you want them in the future, you could do Build | Reload CMake Presets.

{{< figure width="60%" src="remove_temporary_kits.png)

Alternatively, you can keep temporary kits there, but deactivate them for the project. If you accidentally clicked on an unwanted kit in "Build & Run", it got activated. To disable it again, click on its name with right mouse button, and select "Disable Kit for all projects".

{{< figure width="300px" src="disabling_activated_kit.png)

Creating the KDE Builder kit

The very first time you want to use kde-builder with Qt Creator, you will need to create a kit named "KDE Builder kit".

Tip

This kit is a global IDE setting, so you will only need to do it once.

In the left sidebar, switch to "Projects" mode (Ctrl+5), then click "Manage Kits...".

{{< figure width="300px" src="manage_kits_button.png)

Press the "Add" button, and fill in the fields as follows:

Name: "KDE Builder kit"
Logo: select `~/.local/share/kde-builder/logo.png` (optional)
File system name: empty
Run device: Desktop (default for Desktop)
Build device: Desktop (default for Desktop)
Compiler:
   C: select your GCC C compiler
   C++: select your GCC C++ compiler  
Environment: No changes to apply.
Debugger: /usr/bin/gdb
Sysroot: empty
Qt Version: None
Qt mkspec: empty
Additional Qbs Profile Settings: empty
CMake tool: /usr/bin/cmake
CMake generator: Ninja
CMake Configuration:   (without them, our kit will have a warning that they are missing)
```
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
```
Python: None

Configure Build Settings

Open the "Projects" mode (Ctrl + 5), go to "Build & Run", "KDE Builder kit", then click "Build".

The "Build Settings" view will open.

Add new build configuration

Under the "Edit build configuration", press the "Add" button to add a new build configuration, select any type, for example, "Debug", and give it a name, for example, "KDE Builder build configuration".

CMake section

Under the "Build directory" field, enter the build directory of the module, in our example it will be ~/kde/build/kcalc.

Under "Build type", write the build type that was configured in kde-builder. This should be a valid value.

In the "Initial Configuration" tab, press "Batch Edit", then paste the text from the generated file located at ~/kde/src/kcalc/.qtcreator/cmake_Initial_Configuration.txt.

Under "Use Build Environment", press "Details" to expand this setting. Under "Base environment for the CMake configure step", select "Build Environment".

Build Steps section

In the "CMake arguments" field, enter the "-j" and a value of your num-cores option, for example, "-j 10".

Under targets, ensure you selected "all".

Build Environment section

Copy the text from the generated file located at ~/kde/src/kcalc/.qtcreator/cmake_Configure_and_Build_Environment.txt and paste to the text field in this section.

Configure Run settings

Open the "Projects" mode (Ctrl + 5), go to "Build & Run", "KDE Builder kit", then click "Run".

Deployment section

Under "Deploy configuration", press "Add Deploy Step" and select "CMake install".

For convenience, you can rename the configuration as "KDE Builder Deploy configuration"

Run section

In the "Run configuration" field, press Add button, and select "Custom Executable".

Rename the configuration for your convenience, for example as "KDE Builder Run configuration".

In the "Executable" field, specify the path to the installed project binary. In our example, it is ~/kde/usr/bin/kcalc.

Environment section

Click "Details" to expand this setting.

In the "Base environment for this run configuration" select "System Environment".

Copy the text from the generated file located at ~/kde/src/kcalc/.qtcreator/Run_Environment.txt and paste it into the text field in this section.

Start developing

In the left bottom corner, in the configuration selector, ensure the correct configuration is selected (i.e. for the "kcalc" project, the Build, Deploy and Run configurations applied are those that we configured).

You are now ready to start developing.

Switch to "Edit" mode (Ctrl + 2). Open the kcalc.cpp, and make a breakpoint. For example, let's do it in main(). In the text editor's top bar, open the "Select Symbol" drop-down menu, scroll to the bottom of the options, and select the last item in it: main(int, char**) -> int. Click on the line with the opening curly bracket of the function main().

Now when you click the Debug button (that has a green play icon with a bug in its corner), all the preparation steps will be done automatically (CMake configure, build, deploy and run).

The debugger will stop at the breakpoint, and you can inspect variables, step into functions, etc.

Tips and Tricks

Custom executable to run

,

,

Unfortunately, Qt Creator has limited abilities for generating project configuration externally (for more info, see ). So the configuration is made half manually and half automatically.

See official documentation: .

See the official documentation: .

Note: if you want to see debugging messages, you can add corresponding variables here. See for more information.

When developing a library, it may be convenient to launch some application that uses it, from the current project. For example, you work with Ark's libraries used in Dolphin's context menu actions. You can make your run configuration to launch the custom binary dolphin. See to configure that.

sudo apt install qtcreator
sudo pacman -S qtcreator
Qt Creator
build Qt Creator from Git
kde-builder developer documentation
Configuring Projects
Open projects
Using error messages
Qt Creator settings: Specifying a custom executable to run
Kubuntu
KDE Neon
Manjaro
Arch