Qt,非模式对话框不会自行关闭
我有一个主窗口和一个非模式对话框。我想当我关闭主窗口时,非模式对话框应该自行关闭。相反,如果我打开非模式对话框,我应该手动关闭它们 - 如果我关闭主窗口,非模式对话框将保留,我需要手动关闭它。
# App and main window
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
class Window ... :
...
def func:
non_modal_dialog = NonModalDialog()
non_modal_dialog.show()
...
当我关闭主窗口时,我应该怎么做,所有非模式对话框都会自动关闭?
谢谢。
I have one main Window and one non-modal Dialog. I suppose non-modal dialog should close itself when I close main window. Instead if I open non-modal dialog, I should close manually both of them - if I close main window, non-modal dialog will remain, and I need to close it manually.
# App and main window
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
class Window ... :
...
def func:
non_modal_dialog = NonModalDialog()
non_modal_dialog.show()
...
What should I do so when I close main window all non-modal dialogs will be closed automatically?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已将对话框的父窗口小部件设为主窗口或至少是主窗口的某种后代?如果您这样做,那么当窗口消失时,对话框也会消失。我熟悉 Qt,但不熟悉 Python,但从您的代码示例来看,情况并非如此。
Have you made the dialog's parent widget the main window or at least some sort of descendant of the main window? If you do that then the dialog will go away when the window does. I'm familiar with Qt but not Python but it didn't look like that's the case from your code sample.