Qt 6 QML Book更新

Qt 6 QML Book Updates

Qt 6 QML Book更新

Friday March 18, 2022 by Johan Thelin | Comments

​2022年3月18日星期五约翰·塞林 | 评论

The Qt 6 QML Book is about QML and related topics such as how to integrate languages such as C++ and Python to QML, the Qt for MCUs offering, and more. It has been a few months since the last update, so we're going to talk about what happened since the last time around. If you want to go ahead and start reading immediately, you can find the free online book here.

​Qt 6 QML Book书是关于QML和相关主题的,例如如何将C++和Python等语言集成到QML、Qt for MCUs等等。上一次更新已经过去了几个月,所以我们将讨论自上次更新以来发生的事情。如果你想马上开始阅读,你可以在这里找到免费的在线书籍。

Qt for MCUs

The most significant addition to the book is the section on Qt for MCUs. Modern user interfaces are ubiquitous today, and as a consequence, users expect fluid, touch-based user interfaces of smaller and smaller devices. Driving user interfaces from microcontroller class devices is doable, but is often complex. This is where Qt for MCUs and Qt Quick Ultralite enters the picture. It combines the convenience of Qt Quick and QML, with the ability to run on very small systems, that are too resource restricted to run Linux or other operating systems that Qt traditionally targets.

这本书最重要的补充是关于Qt for MCUs的部分。现代用户界面在今天无处不在,因此,用户希望越来越小的设备具有流畅的、基于触摸的用户界面。从微控制器类设备驱动用户界面是可行的,但往往很复杂。这就是Qt for MCU和Qt Quick Ultralite进入画面的地方。它结合了Qt-Quick和QML的便利性,以及在非常小的系统上运行的能力,这些系统的资源非常有限,无法运行Linux或Qt传统上针对的其他操作系统。

Qt for MCUs has been around for a while now and recently reached version 2.0. To make it easier to get started with Qt for MCUs, we've just recently added a chapter on the topic to the Qt 6 book, where we walk through setting up the environment and some typical use cases.

Qt for MCU已经存在了一段时间,最近达到了2.0版。为了更容易地开始使用Qt for MCU,我们最近刚刚在Qt 6书中添加了一章,介绍了环境设置和一些典型用例。

Qt for MCUs targets the bare metal, or small real-time operating systems such as FreeRTOS. This means that the application’s footprint is much smaller, but also that the environment is more restricted. Some of the key differences between Qt and Qt for MCUs are:

Qt for MCU的目标是裸机或小型实时操作系统,如FreeRTOS。这意味着应用程序的占用空间要小得多,但环境也受到了更多的限制。对于MCU,Qt和Qt之间的一些关键区别是:

  • Qt for MCUs is only a front-end framework. Programs must rely on STL and other 3rd party libraries for the functionality that the classic, non-graphical Qt modules provide.
  • Qt for MCU只是一个前端框架。程序必须依赖STL和其他第三方库来实现经典的非图形Qt模块提供的功能。
  • Qt for MCUs compiles QML to a minimized binary, meaning that there is no QML interpreter onboard. This requires things to be more strictly defined, less dynamic, and there are caveats when working with dynamic data.
  • Qt for MCU将QML编译为最小化的二进制文件,这意味着机上没有QML解释器。这要求对事物进行更严格的定义,减少动态性,并且在处理动态数据时需要注意下。
  • Qt for MCUs comes with Qt Quick Ultralite, a sub-set of Qt Quick.
  • Qt for MCU附带在Qt Quick Ultralite中,这是Qt Quick的一个子集。

Generally, all the limitations above do not restrict development, given the capabilities of the target systems. However, one needs to be aware of them and capable of handling the caveats they imply. This is described in detail in the reference documentation. In the Qt 6 Book, the restrictions, and solutions to them, are brought up in the context of the examples.

一般来说,鉴于目标系统的能力,上述所有限制并不限制开发。然而,人们需要意识到它们,并能够处理它们所提示的警告。这在参考文档中有详细描述。在Qt6书中,这些限制和解决方案是在示例的上下文中提出的。

The examples are built up from a simple "Hello World" and include a demonstration of how to mix C++ and QML to exchange properties, signals, and function calls, as well as an example of a C++ model being used to populate a view on the QML side.

这些示例是从一个简单的“hello World”中构建的,包括如何混合C++和QML来交换属性、信号和函数调用,以及一个用于在QML侧填充视图的C++模型的示例。

Compared to a classic Qt code base, one of the biggest changes is that the QObject base class is no longer used. Instead, several classes for creating signals, properties, models, and more are provided. These classes are based around modern C++ and do not involve the meta-object compiler. At the same time, a new compiler is used to extract meta-information about interfaces and models exposed from C++ to QML, and alongside a compiler for converting QML to C++. This means slightly less dynamic code at runtime but a lower footprint and a better result for smaller embedded targets.

与经典的Qt代码库相比,最大的变化之一是不再使用QObject基类。相反,提供了几个用于创建信号、属性、模型等的类。这些类是基于现代C++的,不涉及元对象编译器。同时,使用一个新的编译器来提取从C++到QML的接口和模型的元信息,并将编译器与QML转换成C++。这意味着运行时的动态代码要少一些,但对于较小的嵌入式目标来说,占用空间更小,效果更好。

The chapter also discusses the build environment. As Qt for MCUs compiles QML to C++ prior to deploying it to the target, there are many CMake macros used to register interfaces, compile QML, and such.

本章还讨论了构建环境。由于Qt for MCUs在部署到目标之前将QML编译成C++,因此有许多用于登记接口、编译QML等的CMake宏。

Qt Quick Shapes

Another new chapter covers the Qt Quick Shapes module. The module lets you create and work with path-based shapes in QML. This takes QML beyond rectangles to the land of free-form shapes.

另一个新章节介绍了Qt Quick Shapes模块。该模块允许您在QML中创建和使用基于路径的形状。这将QML从矩形带到自由形状的领域。

This has been possible to achieve using pre-rendered graphics or SVGs for resolution independence. However, using the Qt Quick Shapes module, you can modify the shapes directly using QML's bindings. This lets you adjust shapes, positions, colors, and any other property you can think of on the fly. This includes being able to use QML animations.

这可以通过使用预渲染图形或SVG实现分辨率独立性。但是,使用Qt Quick Shapes模块,可以直接使用QML的绑定修改形状。这可以让你调整形状、位置、颜色和任何其他你能想到的动态属性。这包括能够使用QML动画。

The new chapter complements the older Canvas chapter. The Canvas module is still there and offers the API from the browser canvas, which is very handy for integrating Javascript/web visualization tools into QML scenes.

新的章节补充了旧的画布章节。Canvas模块仍然存在,并提供了浏览器画布上的API,这对于将Javascript/web可视化工具集成到QML场景中非常方便。

Next Steps

下一步

The current development of the book is to create a section on Qt Quick 3D, which is a large topic that is new to the book. The purpose is to create an introduction to the topic step-by-step so that it is easy to start learning about the subject.

本书目前的发展是创建一个关于Qt Quick 3D的部分,这是本书的一个新的大主题。目的是一步一步地介绍这个主题,这样就很容易开始学习这个主题。

There have been many contributions in the form of corrections and bug reports - these are much appreciated and will be addressed before the next release of the book. Thank you!

 在更正和错误报告方面有很多贡献——非常感谢,并将在本书下一次发行之前予以解决。非常感谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值