我不确定这个问题以前有没有人问过,但我已经搜索了一大堆,也许我用错了关键字。我也在谷歌上搜索过,但我想我想要一个更具体的答案
我的问题与几乎每个PyQt4类文档中看到的以下行有关
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a dialog with parent parent.
A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent. It will also share the parent's taskbar entry.
我想明白这到底意味着什么。据我所知,它与对象如何在内存中生存以及它如何与Python的垃圾收集交互有关
更具体一点,假设我有一个QMainWindow,我将它作为父窗口传递给QDialog。在某处我有这样一个函数
def ShowFooDialog():
dlg = FooDialog()
if dlg.exec_():
--doSomeStuff--
这和下面的有什么区别
def ShowFooDialog():
dlg = FooDialog(parent=MyMainWindow)
if dlg.exec_():
--doSomeStuff--
谢谢!如果这是一些可以通过更好地阅读PyQt4文档发现的东西,我提前道歉
目前没有回答
相关问题 更多 >
编程相关推荐