本页内容

Dialog QML Type

本机对话框的基类。更多...

Import Statement: import Qt.labs.platform
Inherits:

QtObject

Inherited By:

ColorDialog, FileDialog, FolderDialog, FontDialog, and MessageDialog

Status: Deprecated since 6.11

自 Qt Labs Platform 6.11 起,此类型已被废弃。我们强烈建议不要在新代码中使用它。

属性

信号

方法

详细说明

请改用QtQuick.Dialogs Dialog 。

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

要显示一个原生对话框,请创建一个具体的 Dialog 实现类的实例,设置所需的属性,然后调用open()。当用户完成对话框操作时,Dialog 会发出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()

关闭对话框。

另请参阅 visible 和open()。

void done(int result)

关闭对话框并设置result 。

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

void open()

打开对话框。

另请参阅 visible 和close()。

void reject()

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

另请参阅 accept()。

© 2026 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.