[PyQt] Re: Subclassed QMainWindow is shown and instantly disappear

Filip Gruszczyński gruszczy at gmail.com
Mon Dec 29 19:05:48 GMT 2008

OK, I finally found out, that it's GC that's deleting the editor.
Still, I have no idea which reference causes it not to delete my other
editors. I'll just keep explicit references and it all should be ok.

2008/12/29 Filip Gruszczyński <gruszczy at gmail.com>:
> I am subclassing QMainWindow to create editors invoked from my browser
> application. This goes like this:
> action = QAction('Edit', self)
> self.connect(action, SIGNAL('triggered()'), resource.invokeEditor)
> menu.addAction(action)
> for most resources everything is ok and the editor is invoked. But for one:
> def invokeEditor(self):
>        DocumentEditor(self).show()
> the editor is first shown and then hidden again. I was using editor
> from PyQt examples (a bit changed). But when I tried it for even a
> simple one like this:
> class DocumentEditor(QMainWindow):
>        def __init__(self, resource):
>                QMainWindow.__init__(self)
>                print "Initializing Document editor"
>                self.__edit = QTextEdit()
>                self.setCentralWidget(self.__edit)
> I can see, that the editor is invoked, but instantly disappears. I
> just can't understand what I am doing suddenly wrong, because for all
> other editors (big editor built dynamically from an xml description
> and graphical editor for plans) work just fine and never disappear.
> What have I forgotten? Do I have to add some parent information?
> --
> Filip Gruszczyński

Filip Gruszczyński

More information about the PyQt mailing list