[PyQt] what is the difference between QMenu() and QMenu(self)

Jian Ma jianmarf at gmail.com
Fri Jul 29 23:18:58 BST 2011


Hi all,

I created a QMenu object in a class. When I created it with menu =
QMenu(self) and run the program, it sometimes got the "segmentation fault"
after exit the program. When I created the object with menu = QMenu(), it
didn't get this problem. I guess the reason is about the QMenu object
ownership. In one case, the object is owned by PyQt. In other case, it is
owned by Qt. I am not sure my guess. Can someone give some explanation?
Below is some code segment.

class DnDMenuListWidget(QListWidget):
    ...
    ...
    def dropEvent(self, event):
        ...
        ...
        menu = QMenu(self)    # using QMenu(self)
        # menu = QMenu()      #  using QMenu()
        ...
        ...

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110729/5893a4a5/attachment.html>


More information about the PyQt mailing list