[PyQt] Problem with destroyed() signal and QMainWindow

Colin McPhail colin.mcphail at talktalk.net
Wed Aug 18 18:34:49 BST 2010


On 18 Aug 2010, at 16:43, dizou wrote:

> 
> I have a QMainWindow that spawns another QMainWindow. When the second
> QMainWindow is closed by the x button in the upper right corner, I want some
> stuff to happen in the first QMainWindow. This is what I have:
> 
> class MainWindow(QMainWindow):
>    def __init__(self):
>        QMainWindow.__init__(self)
>    def EnterDrawMode(self):
>        drawWindow = DrawWindow(self)
>        drawWindow.show()
>        self.connect(drawWindow, SIGNAL("destroyed()"), self.Test)
>    def Test(self):
>        print "exit"
>        #do stuff
> 
> class DrawWindow(QMainWindow):
>    def __init__(self, parent):
>        QMainWindow.__init__(self, parent)
>        self.setObjectName("DrawWindow")
>        self.setFixedSize(200, 200)
> 
> However, when I close DrawWindow, nothing happens. What am I doing wrong?

Does adding the line    self.setAttribute(Wt.WA_DeleteOnClose)   to DrawWindow's __init__ method help?

-- Colin



More information about the PyQt mailing list