因为最近才深入的使用Qt,所以很多常用的属性还不知道怎么设置。今天在写Qt中的弹出对话框的时候,对话框是出来了,但是没处理完对话框,点击对话框以外的窗体位置还是可以和主窗体交互,我记得在winForm编程的时候,应该设置主窗体之类的。而在Qt下称为模态和非模态对话框。
对应的英文文档为:
enum Qt::WindowModality
This enum specifies the behavior of a modal window. A modal window is one that blocks input to other windows. Note that windows that are children of a modal window are not blocked.
The values are:
Constant | Value | Description |
---|---|---|
Qt::NonModal | 0 | The window is not modal and does not block input to other windows. |
Qt::WindowModal | 1 | The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows. |
Qt::ApplicationModal | 2 | The window is modal to the application and blocks input to all windows |
Constant | Value | Description |
---|---|---|
Qt::NonModal | 0 | 非模态,可以和程序的其它窗体交互。 |
Qt::WindowModal | 1 | 窗体模态,程序在未处理完对话框时将阻止和对话框的父窗体、父父窗体以及父窗体的兄弟姐妹窗体及其父窗体交互。 |
Qt::ApplicationModal | 2 | 应用程序模态,阻止和任何其它窗体进行交互。 |