C

Getting Started on Windows

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

Currently, Windows 10 64bit is the only supported development host environment. Additionally, you must have the following tools installed, to build any Qt Quick Ultralite project:

  • MSVC compiler v19.16 (Visual Studio 2017 15.9.9 or newer)
  • CMake 3.15 or newer (you can install it using the Qt Online installer)

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:

C:\Users\John> set Qul_DIR=<INSTALL_ROOT>
C:\Users\John> cd %Qul_DIR%\demos\thermo
<INSTALL_ROOT>\demos\thermo> mkdir build_winqt
<INSTALL_ROOT>\demos\thermo> cd build_winqt
<INSTALL_ROOT>\demos\thermo\build_winqt> 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:

<INSTALL_ROOT>\demos\thermo\build_winqt> cmake --build . --target thermo_big --config Release

Running the built application

Once the thermostat application is built, try to run it. As it is built as a Qt application for Windows, it requires the Qt runtime libraries in the PATH. Qt for MCUs does not require you to install the standard Qt for desktop, instead it provides you with all the necessary libraries. You must ensure that these libraries are in your PATH.

<INSTALL_ROOT>\demos\thermo\build_winqt> set PATH=%Qul_DIR%\bin;%PATH%

Now we can run the application:

<INSTALL_ROOT>\demos\thermo\build_winqt>Release\thermo_big.exe

The Thermostat application window should look like this:

Visual Studio

Setting up the project

To configure the project, follow instructions in the Command line setup section.

Open the solution in Visual Studio

To work with your project using Microsoft Visual Studio, open the solution created by CMake from the build_winqt folder.

Now, you should see the solution tree structure.

As this is a Windows Qt project, it requires Qt's runtime libraries to run. To make them available for the built application, you must set the runtime environment. To do this:

  1. Right-click on your project and select Properties from the context menu.
  2. Click General > Debugging
  3. To Environment add the PATH variable pointing to the directory containing the Qt libraries. Those should be located inside the bin folder of your Qt for MCUs install root, for example:
    PATH=%Qul_DIR%\bin

After this step (assuming %Qul_DIR% was set to C:\QtForMCU\1.1.0) the project properties window should look like this:

Build & run

Apply the changes, build the application, and run it. You should see on the screen the thermostat demo.

Qt Creator Setup

The following sections provides instructions to set up Qt Creator for Qt for MCUs development on the Windows 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 Create Kit to create a kit for the selected target. if a kit already exists, remove it first using Remove Kit.
  6. Click Apply.

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 or Microsoft Visual Studio. 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.