C
Qt Quick ウルトラライトマルチスクリーンの例
Qt Quick Ultraliteでマルチスクリーンを使用する方法を示します。
概要
multiscreen の例では、1つのQt Quick Ultralite アプリケーションでコンテンツを別々の画面に表示する方法を示しています。


対象プラットフォーム
プロジェクト構造
この最小限の例は、CMakeLists.txt 、mcu_multiscreen.qmlproject 、multiscreen.qml の3つのファイルのみで構成されています。
CMakeプロジェクトファイルには基本的なビルドスクリプトが含まれ、multiscreen.qml にはUIが定義され、mcu_minimal.qmlprojectにはmultiscreen.qml をプロジェクトにロードするための簡単なプロジェクト構成が含まれています。
CMakeプロジェクトファイル
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial
cmake_minimum_required (VERSION 3.21.1)
project(multiscreen VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
find_package(Qul)
endif()
qul_add_target(multiscreen QML_PROJECT mcu_multiscreen.qmlproject GENERATE_ENTRYPOINT)
app_target_setup_os(multiscreen)
if(NOT CMAKE_CROSSCOMPILING AND NOT WIN32)
add_custom_command(TARGET multiscreen
COMMAND strip multiscreen -o multiscreen.stripped
DEPENDS multiscreen)
endif()アプリケーションUI
import QtQuick 2.15
import QtQuickUltralite.Layers 2.0
ApplicationScreens {
Screen {
backgroundColor: "#41CD52"
ItemLayer {
anchors.centerIn: parent
depth: ItemLayer.Bpp32Alpha
width: textPrimary.width
height: textPrimary.height
Rectangle {
anchors.fill: parent
color: "#41CD52"
}
Column {
id: textPrimary
anchors.centerIn: parent
spacing: 5
Text {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 30
text: "Qt for MCUs"
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 20
text: "first screen"
}
}
}
}
Screen {
backgroundColor: "#41CD52"
ItemLayer {
z: 1
anchors.centerIn: parent
depth: ItemLayer.Bpp32Alpha
width: textSecondary.width
height: textSecondary.height
Rectangle {
anchors.fill: parent
color: "#41CD52"
}
Column {
id: textSecondary
anchors.centerIn: parent
spacing: 5
Text {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 30
text: "Qt for MCUs"
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 20
text: "second screen"
}
}
}
}
}ファイル