C
新しいプラットフォームにおける初のQt Quick Ultraliteアプリケーション
プラットフォームへの移植が完了したところで、次は移植した環境上でQt Quick Ultraliteアプリケーションを実行してみましょう。
以下の3つのファイルを使用して、移植ガイド全体を通じて使用する、アニメーションとタッチ入力を備えた新しいQMLアプリケーションを作成します。
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"
}
}建物
ビルド以下の手順に従って、サンプルをビルドするための環境を設定します。
QUL_ROOT また、以下のコマンドラインの例では、QUL_TOOLS が環境変数として設定されているかのように使用されています。例:
export QUL_ROOT=$HOME/Qt/QtMCUs/2.12.2
export QUL_TOOLS=$HOME/Qt/Tools/QtMCUsset QUL_ROOT=C:\Qt\QtMCUs\2.12.2
set QUL_TOOLS=C:\Qt\Tools\QtMCUs- ビルドディレクトリを作成します:
mkdir build cd build - 以下のコマンドを使用して、サンプルを構成およびビルドします:
使用しているツールチェーンに応じて、
CMAKE_TOOLCHAIN_FILEを$QUL_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake、$QUL_ROOT/lib/cmake/Qul/toolchain/iar.cmake、または独自に作成したカスタムファイルに設定する必要があります。QUL_TARGET_TOOLCHAIN_DIRは、使用するツールチェーンの場所を指定します。Windowsで
nmakeを使用するには、「VC\Auxiliary\Build 」にあるVisual Studioディレクトリ内のvcvarsx86_amd64.batWindowsバッチファイルを実行してください。あるいは、「x86_x64 Cross Tools Command Prompt for VS 2017」またはお使いの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 .「フラッシュターゲットの作成」セクションの手順に従って、お使いのプラットフォーム用のフラッシュターゲットを作成した場合は、次のコマンドを使用してサンプルをフラッシュしてください。
cmake --build . --target flash_minimal_portingフラッシュが正常に完了すると、デバイスの出力接続から次のようなメッセージが表示されます:
Unable to allocate platform screen for a Screen item, so it will not be visible. Ensure all outputDevice names are correctly set. Hello Worldグラフィックスがまだ実装されていないため、この警告は想定内です。
これで移植ガイドの第一段階が完了しましたので、状態をコミットできます。次の段階では、画面にグラフィックスを表示させることになります。
特定の Qt ライセンスの下で利用可能です。
詳細はこちらをご覧ください。