Dialog QML Type

本地对话框的基类。更多

Import Statement: import Qt.labs.platform
Inherits:

QtObject

Inherited By:

ColorDialog, FileDialog, FolderDialog, FontDialog, and MessageDialog

属性

信号

方法

详细说明

Dialog 类型为本地平台对话框提供了通用的 QML API。

要显示本地对话框,只需构建一个具体 Dialog 实现的实例,设置所需的属性,然后调用open() 即可。当用户完成对话框操作时,对话框会发出accepted() 或rejected() 。

注意: Qt.labs 模块中的类型不保证在未来版本中保持兼容。

属性文档

data : list<QtObject> [default]

该默认属性包含声明为对话框子对象的所有对象的列表。


flags : Qt::WindowFlags

该属性保存对话框的窗口标志。默认值为Qt.Dialog


modality : Qt::WindowModality

该属性用于保存对话框的模式。默认值为Qt.WindowModal

可用值:

常量说明
Qt.NonModal对话框不是模式对话框,不会阻止其他窗口的输入。
Qt.WindowModal对话框对单个窗口层次结构是模式,并阻止对其父窗口、所有祖窗口以及父窗口和祖窗口的所有同级窗口的输入。
Qt.ApplicationModal对话框对应用程序是模态的,并阻止对所有窗口的输入。

parentWindow : Window

该属性用于保存对话框的父窗口。

除非明确设置,否则窗口会通过遍历 QML 父对象自动解析,直到找到Window 或具有窗口的Item


result : int

该属性显示结果代码。

标准结果代码:

常量
Dialog.Accepted
Dialog.Rejected

注: MessageDialog 将结果设置为点击的标准按钮的值,而不是使用标准结果代码。


title : string

该属性用于保存对话框的标题。


visible : bool

该属性表示对话框的可见性。默认值为false

另请参阅 open() 和close()。


信号文档

void accepted()

当以交互方式或调用accept() 接受对话框时,将发出此信号。

注: 使用close() 关闭对话框时不会发出此信号。

注: 相应的处理程序是onAccepted

另请参阅 rejected()。


void rejected()

当以交互方式或调用reject() 拒绝对话框时,将发出此信号。

注: 使用close() 关闭对话框时不会发出此信号。

注: 相应的处理程序是onRejected

另请参阅 accepted()。


方法文档

void accept()

关闭对话框并发出accepted() 信号。

另请参阅 reject() 。


void close()

关闭对话框。

另请参阅 visibleopen()。


void done(int result)

关闭对话框并设置result

另请参阅 accept()、reject() 和result


void open()

打开对话框。

另请参阅 visibleclose()。


void reject()

关闭对话框并发出rejected() 信号。

另请参阅 accept() 。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.