Qt中设置对话框的属性

        因为最近才深入的使用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::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
ConstantValueDescription
Qt::NonModal 0 非模态,可以和程序的其它窗体交互。
Qt::WindowModal 1 窗体模态,程序在未处理完对话框时将阻止和对话框的父窗体、父父窗体以及父窗体的兄弟姐妹窗体及其父窗体交互。
Qt::ApplicationModal 2 应用程序模态,阻止和任何其它窗体进行交互。
属性设置:dialog->setWindowModality ( Qt :: ApplicationModal );
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值