Dialogs in Qt Quick
Qt Quick中的对话框
September 29, 2022 by Oliver Eftevaag | Comments
2022年9月29日,奥利弗·埃夫特瓦格 | 评论
The Qt Quick Dialogs module has undergone a lot of changes in the last two years. Its purpose has always been to make it simple for developers to add dialogs to their applications. Native dialogs should be used by default on platforms that have a native dialog for a specific dialog type, and if the system can't provide one, then the module should fall back to a suitable dialog that's implemented in Qt.
Qt快速对话模块在过去两年经历了很多变化。它的目的始终是让开发人员能够简单地将对话框添加到他们的应用程序中。默认情况下,在具有特定对话框类型的本地对话框的平台上应使用本地对话框,如果系统无法提供本地对话框,则模块应返回到Qt中实现的合适对话框。
With the release of Qt 6 we removed the previous Qt Quick Controls 1 module, which the Qt Quick Dialogs module depended on at the time. Because of this, we ended up rewriting the module from scratch, and we've been gradually introducing the various dialogs back into the module since Qt 6.2. The new fallback dialogs are now based on the Qt Quick Controls 2 module, which means that we've taken extra care to ensure that they all look good with each Qt Quick Controls Style.
随着Qt 6的发布,我们删除了以前的Qt Quick Controls 1模块,Qt Quick-Dialogs模块当时依赖于该模块。因此,我们最终从头开始重写模块,并从Qt 6.2开始逐步将各种对话框引入模块。新的回退对话框现在基于Qt Quick Controls 2模块,这意味着我们已经格外小心,以确保它们在每种Qt Quick Controls样式下都看起来很好。
In Qt 6.2 we reintroduced the FileDialog and the FontDialog.
在Qt 6.2中,我们重新引入了FileDialog和FontDialog。
In Qt 6.3 we reintroduced the FolderDialog and the MessageDialog.
在问题6.3中,我们重新引入了FolderDialog和MessageDialog。
In Qt 6.4 we're reintroducing the ColorDialog.
在问题6.4中,我们重新引入了ColorDialog。
FileDialog
文件对话框
The file dialog will be native by default on Windows, macOS, Android, iOS and Gtk.
The screenshots below demonstrate the fallback dialogs in each Qt Quick Controls style:
在Windows、macOS、Android、iOS和Gtk上,文件对话框默认为本地的。
下面的屏幕截图演示了每个Qt Quick Controls样式中的回退对话框:
Basic style | Fusion style |
Imagine style | Material style |
Universal style |
FontDialog
字体对话框
The font dialog is native by default on macOS and Gtk.
The fallback dialog will look like the following for the various styles:
默认情况下,字体对话框在macOS和Gtk上是本地的。
各种样式的回退对话框如下所示:
Basic style | Fusion style |
Imagine style | Material style |
Universal style |
FolderDialog
文件夹对话框
The FolderDialog will naturally share a lot of similarities with the FileDialog.
It's native by default on Windows, macOS, iOS, Android and Gtk. The fallback dialog will look like the following images:
FolderDialog自然与FileDialog有很多相似之处。
默认情况下,它在Windows、macOS、iOS、Android和Gtk上是本地的。回退对话框将如下图所示:
Basic style | Fusion style |
Imagine style | Material style |
Universal style |
MessageDialog
消息对话框
The message dialog is a pretty basic dialog that will be native by default on iOS and Android.
Otherwise it will look like the following for the various styles:
消息对话框是一个非常基本的对话框,在iOS和Android上默认为本地对话框。
否则,对于各种样式,它将如下所示:
Basic style | Fusion style |
Imagine style | Material style |
Universal style |
ColorDialog
颜色对话框
The color dialog is the newest addition to the family.
It will be native by default on macOS and Gtk, and otherwise will look like the following for the various styles.
颜色对话框是该族的最新添加项。
默认情况下,在macOS和Gtk上它将是本地的,否则,对于各种样式,它将类似于以下内容。
Basic style | Fusion style |
Imagine style | Material style |
Universal style |
Future work
后续工作
While 6.4 adds the last remaining dialog, we still have more features that we wish to introduce in the future.
虽然6.4增加了最后一个对话框,但我们仍然有更多的特性希望在将来介绍。
The fallback dialogs are implemented as items in the scene, rather than true top-level windows This is advantageous on some platforms, like embedded platforms, mobile and web assembly, but we know that desktop users will likely prefer top level windows by default. This is something that we would like to fix in a future release.
回退对话框是作为场景中的项目实现的,而不是真正的顶级窗口。这在某些平台上是有利的,如嵌入式平台、移动和web组装,但我们知道桌面用户默认情况下可能更喜欢顶级窗口。这是我们希望在未来版本中修复的问题。
We also want to introduce more features in the color dialog to make it as powerful as color pickers in designer applications.
我们还希望在颜色对话框中引入更多功能,使其与设计器应用程序中的颜色选择器一样强大。