C
First Qt Quick Ultralite application on new platform
Now that your platform port is done, it is time to get a Qt Quick Ultralite application running on top of the port.
Create a new QML application with an animation and touch input to be used thoughout the porting guide, using these three files:
CMakeLists.txt
cmake_minimum_required (VERSION 3.21.1)
project(minimal_porting VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
find_package(Qul)
endif()mcu_minimal_porting.qmlproject
import QmlProject 1.3
Project {
mainFile: "minimal_porting.qml"
}minimal.qml
import QtQuick 2.15
Rectangle {
Component.onCompleted: {
console.log("Hello World")
}
color: "forestgreen"
Rectangle {
width: 80
height: 80
anchors.centerIn: parent
SequentialAnimation on width {
running: true
loops: Animation.Infinite
PropertyAnimation {
to: width/2;
duration: 1000;
easing.type: Easing.InOutQuad
}
PropertyAnimation {
to: width/4;
duration: 1000;
easing.type: Easing.InOutQuad
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
if (parent.color == 'silver')
parent.color = 'forestgreen';
else
parent.color = 'silver';
}
}
Text {
anchors.centerIn: parent
font.pixelSize: 30
text: "Qt for MCUs"
}
}Building
The following steps set up your environment for building the example.
QUL_ROOT and QUL_TOOLS are used in the command line examples below as if they were set as environment variables. For example:
export QUL_ROOT=$HOME/Qt/QtMCUs/2.10.1 export QUL_TOOLS=$HOME/Qt/Tools/QtMCUs
set QUL_ROOT=C:\Qt\QtMCUs\2.10.1 set QUL_TOOLS=C:\Qt\Tools\QtMCUs
- Create a build directory:
mkdir build cd build
- Configure and build the example using the following commands:
Depending on the used toolchain you have to set
CMAKE_TOOLCHAIN_FILEto$QUL_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake,$QUL_ROOT/lib/cmake/Qul/toolchain/iar.cmakeor your custom file, if you created your own.QUL_TARGET_TOOLCHAIN_DIRspecifies the location of the toolchain to be used.To use
nmakeon Windows, run thevcvarsx86_amd64.batWindows batch file, which is found in the "VC\Auxiliary\Build" Visual Studio directory. Alternatively, you can run "x86_x64 Cross Tools Command Prompt for VS 2017" or the equivalent for your version of Visual Studio.cmake .. -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=$QUL_ROOT/lib/cmake/Qul/toolchain/<YOUR_TOOLCHAIN>.cmake -DQUL_TARGET_TOOLCHAIN_DIR=/path/to/the/toolchain -DQUL_GENERATORS=$QUL_ROOT/lib/cmake/Qul/QulGenerators.cmake -DQUL_PLATFORM=<YOUR_PLATFORM> cmake --build .
cmake .. -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=%QUL_ROOT%\lib\cmake\Qul\toolchain\<YOUR_TOOLCHAIN>.cmake -DQUL_TARGET_TOOLCHAIN_DIR=C:\path\to\the\toolchain -DQUL_GENERATORS=%QUL_ROOT%\lib\cmake\Qul\QulGenerators.cmake -DQUL_PLATFORM=<YOUR_PLATFORM> cmake --build .
If you have created flash targets for your platform as per the instructions in the Creating flash targets section, flash the example using the following command:
cmake --build . --target flash_minimal_porting
After successful flashing, you should receive the following messages from the device output connection:
Unable to allocate platform screen for a Screen item, so it will not be visible. Ensure all outputDevice names are correctly set. Hello World
The warning is expected because no graphics has been implemented yet.
You have now completed the first phase of the porting guide and can commit your state. The next phase will be getting graphics on the screen.
Available under certain Qt licenses.
Find out more.