Qt-Quick 介绍

本文探讨Qt Quick和QML在不同平台上的应用优势,特别是在嵌入式和移动设备上,QML能够利用GPU加速提升性能。文章对比了widgets与QML的优缺点,并介绍了基于QML开发Qt应用的资源、示例和作品。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 简介

2 优缺点

widgets 只能由CPU渲染,不能利用 opengl 加速。而 qml 则可以。

在桌面平台,大家的CPU往往性能过剩,widgets 还是满足需求的。
在嵌入式平台,很多低端设备甚至都没有图形加速器,或不支持opengl,只能用widgets
在移动端平台,没有gpu加速可能就会“不丝滑”,手感不好。所以用 qml 会有更好的体验

我在做一个demo, UVC Camera上来一帧显示一帧, 实际上在QOpenGLWidget的paintEvent里刷帧(没使用OpenGL) 照样很占CPU, 我认为一定要用paintGL

互联网,顺手就行,性能不用考虑
嵌入式电子设备、物联网,必须是c/c++才行。关键代码只能是C,C++都用不了 …

使用 QML 语言进行 Qt 应用程序开发可以将界面开发和逻辑控制分开,提高应用的开发周期和灵活性;另外对于多媒体应用非常重要的一点是,基于 QML/Qt Quick 的应用程序可以直接调用 GPU 进行加速,这大大提高了多媒体应用在嵌入式系统环境下的处理效率和资源占用
性能
https://www.toradex.com/zh-cn/blog/qian-ru-shilinux-ji-yuqml-kai-faqt-multimedia-ying-yong

3 资料汇总

3.1 书籍

3.2 网站

3.3 博客

4 示例

https://support.crosscontrol.com/kb/qtquick-qml-programming
在这里插入图片描述
In this article, one approach will be presented how signals in the Data Engine can be connected to QML components. Signal values can either be presented in the GUI for a user or be updated through user input with the GUI.
Goal:

  • Set signal value from GUI (qml) and send the value to the Data Engine
  • Read value from Data Engine and view it in the GUI (qml)
    Achieved by:
  • Write a C++ backend to handle communication with Data Engine
  • Class with Q Properties defines the signals
  • QML-binds to properties in the signal class handler
    The following structure will be used for both projects to achieve the previously mentioned goal:
    在这里插入图片描述
    Viewer
  • The Viewer is what the user will see and interact with. It is written with QML and property bindings will be used to bind certain component properties. It communicates with the backend parts Data Engine Control or Data Engine Signal.

Data Engine Signal

  • Defines the signals which should be used by the application. Signals are created as properties which the Viewer can bind to. The name of the signals must follow a specific pattern for the current implementation. Will be presented further on in the article.

Data Engine Control

  • A central piece for this project and the backend. It handles the communication with the Data Engine through the sapcore interface or by receiving data from the observer. It is also responsible to update signals defined as properties in Data Engine Signal.

Observer

  • Receives data from the sapcore interface, such as subscribe result or data for updated signals. Pushes the information to the Data Engine Control which then handles the received data. It’s a part of the Data Engine Control.

Receiver
Signal updates are received from the Observer which is a part of the Data Engine Control. Once a new value arrives, the ID will be checked in one of the used dictionaries to find the corresponding signal name. Once found, it will use the signal handle previously set during the initialization to update the correct property in Data Engine Signal. The property is updated using the WRITE method associated to the signal, which will trigger the GUI to read the new value thanks to the notify signal.
在这里插入图片描述
Sender
When Data Engine Signals emits the signal to send data, the slot connected to the signal will be activated, in this case sendToServer(value,name). The method needs to get the ID associated with the name of the signal, this is done by reading the name paired with the key value ID. Once the ID is known, it is just a matter to set the value using the SAP method SetValue(id,value) available in the sapcore-library.
在这里插入图片描述

5 作品

记录开源Qt/Qml 作品链接

参考

1、
2、怎么看 widgets 与 qml 未来的发展
3、QOpenGLWidget 绘图选择paintEvent还是 paintGL,两者有什么区别吗?都能开启硬件加速吗?
4、学 Qt-widget 还是 Qt-quick?求大佬指教
5、i.mx6q 移植Qt5.9.1(完美支持opengl、Qt quick2、QML)
6、QML移植到ARM
7、移植Qt5.6到imx6系列处理器移植过程说明–支持qml
8、嵌入式Linux基于QML开发QT Multimedia应用
9、显著改善了Qt Quick 和 QML之性能,尤其在ARM平台上之Linux。QML引擎,Qt Quick 图形,Qt QML编译器,Qt Quick 控件,相对于5.6,有些方面的性能提高了数倍。
10、Template:FriendlyCoreRK3399QtDev/zh
11、Qt Quick 之 QML 与 C++ 混合编程详解
12、Introduction to Qt Quick for C++ Developers

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

worthsen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值