C

Getting Started on Linux

Overview

This topic provides instructions to compile a Qt Quick Ultralite project for Qt Desktop. The Qt Desktop environment lets you quickly preview the application you are developing, making the process of creating the application faster.

As a reference project let's use the thermostat demo provided with Qt for MCUs.

Prerequisites

To start development with Qt Quick Ultralite you must have the following tools installed:

  • GNU Compiler Collection v7.4.0 or newer
  • GNU Make
  • X C Binding, xinerama extension library (libxcb-xinerama0)
  • CMake 3.15 or newer (you can install it using the Qt Online installer)

All these prerequisites can be installed using the following commands:

sudo apt update
sudo apt install build-essential libxcb-xinerama0 cmake

In addition, install Qt for MCUs using the Qt online installer that is available for download on Qt account.

Important: This guide uses <INSTALL_ROOT> as the reference to directory the Qt for MCUs is installed in.

Command line

Setting up the project

To configure the project, use the CMake command from the command line. First, navigate to the <INSTALL_ROOT>/demos/thermo folder and enter the following commands:

export Qul_DIR=<INSTALL_ROOT>
cd $Qul_DIR/demos/thermo
mkdir build_linuxqt
cd build_linuxqt
cmake .. -DQUL_PLATFORM=Qt -Ax64

The above commands will check the prerequisites and create the build setup, which includes generating visual studio project files.

Building

To build, use the following command:

cmake --build . --target thermo_big --config Release

Running the built application

Once the thermostat application is built, try to run it:

./thermo_big

The Thermostat application window should look like this:

Qt Creator Setup

The following sections provides instructions to set up Qt Creator for Qt for MCUs development on the Linux platform only. For details about configuring Qt Creator for development on MCU boards, refer to Qt Creator documentation.

Configure the Qt Creator IDE

To develop for MCUs using the Qt Creator IDE, the MCU plugin is required. The Qt online installer enables it by default when you install the Qt for MCUs SDK.

To enable or disable the plugin, follow these instructions:

  1. Select Help > About Plugins and choose the MCU Support plugin from the list.
  2. Restart Qt Creator to apply changes

To build and run your application on MCUs, you must create a kit:

  1. Select Tools > Options > Devices > MCU
  2. If not already set, provide the path to the Qt for MCUs installation directory.
  3. Select a Target supported by the Qt for MCUs SDK. For example, Qt for MCUs dev - Desktop.
  4. In the Requirements section, ensure that the platform-specific requirements are met.
  5. Select Automatically create kits for all available targets on start to create kits automatically.

    Note: You could also manually create/remove kits using Create Kit and Remove Kit.

  6. Click Apply and restart Qt Creator if you choose to create kits automatically.

Note: The Automatically create kits for all available targets on start option is available from Qt Creator v4.14 onwards. On older versions of Qt Creator, you have to explictly create or remove kits using Create kit or Remove kit.

Opening the Thermostat project

To open the Thermostat project:

  1. Select File > Open File or Project...
  2. Open the CMakefiles.txt file from thermo folder.
  3. Select Qt for MCUs dev - Desktop kit.
  4. Click Configure Project to finish.

The project should be configured.

Now, you are ready to go!

Note: For more information, refer to the Qt Creator manual.

Debugging

You can debug the C++ code generated from your application using the Qt Creator. To make debugging a bit easier, in the generated code you will see snippets of the QML, from which the C++ code was generated.

Available under certain Qt licenses.
Find out more.