PyQt:等到小部件关闭 [英] PyQt: Wait until widget closes

查看:52
本文介绍了PyQt:等到小部件关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在我按下按钮后显示的窗口/小部件,有没有办法让主窗口等到小部件关闭?我现在正在使用 .show() 并且我已经尝试使用 .exec_() 但它给了我这个错误:

I have a window/widget that shows after I press a button, is there a way to make the main window wait until the widget closes out? I am using .show() right now and I have tried using .exec_() already but it gives me this error:

AttributeError: 'MainWindow' 对象没有属性 'exec_'

有什么帮助吗?

推荐答案

更改 模态,以便它阻止对其父窗口的输入:

Change the modality of the window/widget so that it blocks input to its parent window:

widget.setWindowModality(QtCore.Qt.WindowModal)

或整个应用程序:

widget.setWindowModality(QtCore.Qt.ApplicationModal)

这篇关于PyQt:等到小部件关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆