您的位置:首页 > 编程语言 > Qt开发

Qt中设置对话框的属性

2012-08-13 09:35 459 查看
因为最近才深入的使用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:

ConstantValueDescription
Qt::NonModal0The window is not modal and does not block input to other windows.
Qt::WindowModal1The 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::ApplicationModal2The window is modal to the application and blocks input to all windows
ConstantValueDescription
Qt::NonModal0非模态,可以和程序的其它窗体交互。
Qt::WindowModal1窗体模态,程序在未处理完对话框时将阻止和对话框的父窗体、父父窗体以及父窗体的兄弟姐妹窗体及其父窗体交互。
Qt::ApplicationModal2应用程序模态,阻止和任何其它窗体进行交互。
属性设置:dialog->setWindowModality(Qt::ApplicationModal);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐