Dialog QML Type
本地对话框的基类。更多
| Import Statement: | import Qt.labs.platform |
| Inherits: | |
| Inherited By: | ColorDialog, FileDialog, FolderDialog, FontDialog, and MessageDialog |
| Status: | Deprecated since 6.11 |
自 Qt.labs.platform 6.11 起,该类型已被弃用。我们强烈建议不要在新代码中使用它。
属性
- data : list<QtObject>
- flags : Qt::WindowFlags
- modality : Qt::WindowModality
- parentWindow : Window
- result : int
- title : string
- visible : bool
信号
方法
详细说明
使用QtQuick.Dialogs Dialog 代替。
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 。
信号文档
void accepted()
当以交互方式或调用accept() 接受对话框时,将发出此信号。
注: 使用close() 关闭对话框时不会发出此信号。
注: 相应的处理程序是onAccepted 。
另请参阅 rejected()。
void rejected()
当以交互方式或调用reject() 拒绝对话框时,将发出此信号。
注: 使用close() 关闭对话框时不会发出此信号。
注: 相应的处理程序是onRejected 。
另请参阅 accepted()。
方法文档
void accept()
关闭对话框并发出accepted() 信号。
另请参阅 reject().
void close()
关闭对话框。
void done(int result)
关闭对话框并设置result 。
另请参阅 accept(),reject() 和result 。
void open()
打开对话框。
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.