C
Qt Quick Ultralite 温控器演示
演示了一个基于Qt Quick Ultralite构建的纯QML应用程序。
概述
本示例展示了开发人员在开发生产就绪型应用程序时可能遇到的多个方面:
- 在单个应用程序中处理不同的目标显示分辨率
- 将使用Qt Quick Ultralite 构建的应用程序进行本地化(英语、德语、日语、阿拉伯语、泰语和印地语)
- 使用不同单位(公制和英制)对应用程序进行本地化
基准测试模式
在基准测试模式下,应用程序将运行预设的30秒时间,并在30秒间隔结束时在屏幕上显示性能指标。如果Qt Quick Ultralite核心库是使用QUL_ENABLE_PERFORMANCE_CONSOLE_OUTPUT=ON 构建的,则相同的结果也会显示在串行控制台上。
测试结束时将显示以下性能指标:
| 参数 | 描述 | |
|---|---|---|
| 1 | 总帧数 | 录制时间段内的帧总数。 |
| 2 | 平均帧率 | 录制期间测得的平均每秒帧数。 |
| 3 | 最低帧率 | 录制期间捕获的最低帧率值。 |
| 4 | 最大堆内存使用量 | 自应用程序启动以来记录的最大堆内存使用量(单位:字节)。 |
| 5 | 最大栈使用量 | 自应用程序启动以来记录的栈最大使用量(以字节为单位)。 |
| 6 | 平均 CPU 负载 | 记录时间段内计算出的平均 CPU 负载百分比。 |
基准测试模式作为独立的 CMake 目标提供,名称分别为thermo_small_benchmark 和thermo_big_benchmark 。要运行基准测试模式,请构建并烧录基准测试模式目标二进制文件。
主 qmlproject 文件包含 benchmark_module.qmlproject 文件,如下所示:
ModuleFiles {
files: [
"mode/benchmark_module.qmlproject"
]
}在根 QML 文件中导入以下模块。
import QtQuickUltralite.Extras 2.0 import Benchmark 1.0 import QtQuickUltralite.Profiling
- Qt Quick Ultralite Extras 该模块提供QulPerf 对象,用于启动和停止测量。
Benchmark该模块由benchmark_module.qmlproject文件提供。它提供了用于模拟轻扫控制触控手势的方法。- Qt Quick Ultralite Profiling 该模块提供了屏幕叠加层QulPerfOverlay ,用于在应用程序用户界面上方显示性能指标。
在根 QML 文件中添加用于显示基准测试结果的QulPerfOverlay QML 对象。当 30 秒后触发 `benchmarkTimer ` 事件时,该覆盖层将显示出来。
QulPerfOverlay {
id: benchmarkResult
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
visible: false
}在根 QML 文件rootqml/+benchmark/thermo.qml 中,当根对象被实例化且触发Component.onCompleted 信号时,开始录制。
Component.onCompleted: {
QulPerf.recording = true
}应用程序运行 30 秒。30 秒后录制停止,并显示基准测试结果屏幕覆盖层。
Timer {
id: benchmarkTimer
interval: 30000
running: true
repeat: false
onTriggered: {
QulPerf.recording = false;
benchmarkResult.visible = true
}
}注意:基准测试模式 要求Qt Quick Ultralite Core 和 Platform 库必须使用QUL_ENABLE_PERFORMANCE_LOGGING=ON 和QUL_ENABLE_HARDWARE_PERFORMANCE_LOGGING=ON 进行构建。
文件变体
恒温器演示程序包含用于精简版 UI 和基准测试模式的文件变体及选择器。要导出基准测试模式的源代码,请应用"benchmark" 文件选择器;要导出精简版 UI 变体的源代码,请使用"small" 文件选择器
qmlprojectexporter --selector benchmark,small demos/thermo/qmlproject/thermo.qmlproject
使用 CMake 构建时,系统会自动考虑这些选择器,并生成如上所述的常规目标和基准测试目标。
目标平台
屏幕截图
适用于小屏幕的温控器演示



适用于大屏幕的恒温器演示



文件:
- thermo/+ra8d1/StatsContents.qml
- thermo/+ra8d1/Theme.qml
- thermo/+small/Theme.qml
- thermo/AnimatedDigit.qml
- thermo/BottomBar.qml
- thermo/CMakeLists.txt
- thermo/Card.qml
- thermo/CardRow.qml
- thermo/ErrorScreen.qml
- thermo/FanControlButton.qml
- thermo/LanguageButton.qml
- thermo/LanguageDialog.qml
- thermo/PlacesView.qml
- thermo/PowerSwitch.qml
- thermo/RoomControlButton.qml
- thermo/RoomSchedule.qml
- thermo/RoomView.qml
- thermo/ScheduleView.qml
- thermo/StatsContents.qml
- thermo/StatsView.qml
- thermo/Theme.qml
- thermo/ThermoView.qml
- thermo/TimeIntervalSlider.qml
- thermo/TimeIntervalSliderHandle.qml
- thermo/TopBar.qml
- thermo/WeatherStatus.qml
- thermo/dynamic/Configuration.qml
- thermo/fonts/Spark/FontConfiguration.qml
- thermo/fonts/Static/FontConfiguration.qml
- thermo/imperial/Units.qml
- thermo/imports/Thermo/ColorStyle.qml
- thermo/imports/Thermo/GlobalState.qml
- thermo/imports/Thermo/Room.qml
- thermo/imports/Thermo/Rooms.qml
- thermo/imports/Thermo/qmldir
- thermo/imports/ThermoConfiguration/qmldir
- thermo/metric/Units.qml
- thermo/mode/+benchmark/benchmark_module.qmlproject
- thermo/mode/+benchmark/simulation/flickControl.cpp
- thermo/mode/+benchmark/simulation/flickControl.h
- thermo/mode/benchmark_module.qmlproject
- thermo/qmlproject/thermo.qmlproject
- thermo/qmlproject/thermo_configuration_module.qmlproject
- thermo/qmlproject/thermo_mimxrt1064.qmlproject
- thermo/qmlproject/thermo_module.qmlproject
- thermo/qmlproject/thermo_ra8d1.qmlproject
- thermo/qmlproject/thermo_stm32.qmlproject
- thermo/rootqml/+benchmark/thermo.qml
- thermo/rootqml/thermo.qml
- thermo/src/os/baremetal/main.cpp
- thermo/static/Configuration.qml
- thermo/thermo.ar_EG.ts
- thermo/thermo.de_DE.ts
- thermo/thermo.en_GB.ts
- thermo/thermo.hi_IN.ts
- thermo/thermo.ja_JP.ts
- thermo/thermo.th_TH.ts
图片:
- thermo/SparkFE/+small/popup-bg.png
- thermo/SparkFE/popup-bg.png
- thermo/StaticFE/+small/popup-bg.png
- thermo/StaticFE/popup-bg.png
- thermo/images/+ra8d1/stats-month.png
- thermo/images/+ra8d1/stats-year.png
- thermo/images/+ra8d1/top-bar-shadow.png
- thermo/images/+small/EGYPT.png
- thermo/images/+small/GERMANY.png
- thermo/images/+small/INDIA.png
- thermo/images/+small/JAPAN.png
- thermo/images/+small/Static/popup-bg.png
- thermo/images/+small/THAILAND.png
- thermo/images/+small/UK.png
- thermo/images/+small/auto-card.png
- thermo/images/+small/auto-on.png
- thermo/images/+small/baseline-arrow-back.png
- thermo/images/+small/btn-bg-big-off.png
- thermo/images/+small/btn-bg-big-on.png
- thermo/images/+small/btn-bg-down.png
- thermo/images/+small/change-language.png
- thermo/images/+small/close.png
- thermo/images/+small/digitMaskBottom.png
- thermo/images/+small/digitMaskTop.png
- thermo/images/+small/dryer-on-small.png
- thermo/images/+small/dryer-on.png
- thermo/images/+small/eco-on-small.png
- thermo/images/+small/eco-on.png
- thermo/images/+small/fan-1-on-small.png
- thermo/images/+small/fan-1-on.png
- thermo/images/+small/fan-2-on-small.png
- thermo/images/+small/fan-2-on.png
- thermo/images/+small/fan-3-on-small.png
- thermo/images/+small/fan-3-on.png
- thermo/images/+small/fan-4-on-small.png
- thermo/images/+small/fan-4-on.png
- thermo/images/+small/fan-off-small.png
- thermo/images/+small/fan-off.png
- thermo/images/+small/jog-off.png
- thermo/images/+small/jog.png
- thermo/images/+small/page-indicator.png
- thermo/images/+small/place-back.png
- thermo/images/+small/popup-bg.png
- thermo/images/+small/power-on.png
- thermo/images/+small/pressed-bg-down.png
- thermo/images/+small/pressed-bg-up.png
- thermo/images/+small/qt-logo.png
- thermo/images/+small/radiobutton-checked-pressed.png
- thermo/images/+small/radiobutton-checked.png
- thermo/images/+small/radiobutton-pressed.png
- thermo/images/+small/radiobutton.png
- thermo/images/+small/scrollbar-off-track.png
- thermo/images/+small/scrollbar-temperature-track.png
- thermo/images/+small/selected.png
- thermo/images/+small/separator-line.png
- thermo/images/+small/slider-handle.png
- thermo/images/+small/stats-month.png
- thermo/images/+small/stats-year.png
- thermo/images/+small/status-small.png
- thermo/images/+small/streamer-on-small.png
- thermo/images/+small/streamer-on.png
- thermo/images/+small/switch-bg.png
- thermo/images/+small/switch-handle.png
- thermo/images/+small/switch-i.png
- thermo/images/+small/switch-o.png
- thermo/images/+small/temp-down-pressed.png
- thermo/images/+small/temp-up-pressed.png
- thermo/images/+small/thermo-handle.png
- thermo/images/+small/toggle-month.png
- thermo/images/+small/toggle-year.png
- thermo/images/+small/top-bar-shadow.png
- thermo/images/EGYPT.png
- thermo/images/GERMANY.png
- thermo/images/INDIA.png
- thermo/images/JAPAN.png
- thermo/images/Static/popup-bg.png
- thermo/images/THAILAND.png
- thermo/images/UK.png
- thermo/images/auto-card.png
- thermo/images/auto-on.png
- thermo/images/baseline-arrow-back.png
- thermo/images/btn-bg-big-off.png
- thermo/images/btn-bg-big-on.png
- thermo/images/btn-bg-down.png
- thermo/images/card-back-bottomleft.png
- thermo/images/card-back-bottomright.png
- thermo/images/card-back-topleft.png
- thermo/images/card-back-topright.png
- thermo/images/change-language.png
- thermo/images/close.png
- thermo/images/digitMaskBottom.png
- thermo/images/digitMaskTop.png
- thermo/images/dryer-on-small.png
- thermo/images/dryer-on.png
- thermo/images/eco-on-small.png
- thermo/images/eco-on.png
- thermo/images/error-text.png
- thermo/images/fan-1-on-small.png
- thermo/images/fan-1-on.png
- thermo/images/fan-2-on-small.png
- thermo/images/fan-2-on.png
- thermo/images/fan-3-on-small.png
- thermo/images/fan-3-on.png
- thermo/images/fan-4-on-small.png
- thermo/images/fan-4-on.png
- thermo/images/fan-off-small.png
- thermo/images/fan-off.png
- thermo/images/inner-circle.png
- thermo/images/jog-off.png
- thermo/images/jog.png
- thermo/images/page-indicator.png
- thermo/images/place-back.png
- thermo/images/power-on.png
- thermo/images/pressed-bg-down.png
- thermo/images/pressed-bg-up.png
- thermo/images/qt-logo.png
- thermo/images/radiobutton-checked-pressed.png
- thermo/images/radiobutton-checked.png
- thermo/images/radiobutton-disabled.png
- thermo/images/radiobutton-pressed.png
- thermo/images/radiobutton.png
- thermo/images/scrollbar-off-track.png
- thermo/images/scrollbar-temperature-track.png
- thermo/images/selected.png
- thermo/images/separator-line.png
- thermo/images/slider-handle.png
- thermo/images/stats-month.png
- thermo/images/stats-year.png
- thermo/images/status-small.png
- thermo/images/streamer-on-small.png
- thermo/images/streamer-on.png
- thermo/images/switch-bg.png
- thermo/images/switch-handle.png
- thermo/images/switch-i.png
- thermo/images/switch-o.png
- thermo/images/temp-down-pressed.png
- thermo/images/temp-up-pressed.png
- thermo/images/thermo-handle.png
- thermo/images/toggle-month.png
- thermo/images/toggle-year.png
- thermo/images/top-bar-shadow.png
- thermo/images/weather/+small/w_01.png
- thermo/images/weather/+small/w_02.png
- thermo/images/weather/+small/w_03.png
- thermo/images/weather/+small/w_04.png
- thermo/images/weather/+small/w_05.png
- thermo/images/weather/+small/w_06.png
- thermo/images/weather/+small/w_07.png
- thermo/images/weather/w_01.png
- thermo/images/weather/w_02.png
- thermo/images/weather/w_03.png
- thermo/images/weather/w_04.png
- thermo/images/weather/w_05.png
- thermo/images/weather/w_06.png
- thermo/images/weather/w_07.png
在某些 Qt 许可下可用。
了解更多信息。