QWidget设置为模态问题

时间:2023-03-09 15:33:06
QWidget设置为模态问题

设置QWidget的Qt::WindowModality属性为Qt::WindowModal和Qt::ApplicationModal,发现窗体仍然不会模态,网上查了一下,有人说改属性只对window有效,找了很多方法,验证原因是因为我的QWidget有Parent,如果构造时设置Parent为NULL的话,就可以了。

以下是工作中用到的常用窗体属性:

setWindowFlags(Qt::FramelessWindowHint);//去除窗体边框 tWindowModality(Qt::ApplicationModal);//设置窗体模态,要求该窗体没有父类,否则无效 Attribute(Qt::WA_TranslucentBackground, true);//设置边框阴影图片时用到

相关文章