Issue
I have my main application QWindow
where, when I press a QPushButton a new child window (a QWidget
) pops up. There are two ways of exiting the QWidget
window:
- Click the X in the top right hand corner, or
- Click on the 'Finished'
QPushButton
I have in theQWidget
window.
I would like to ensure that, when either method is used to exit the window, the QWidget
is deleted. I believe that I can ensure this in the second case by adding self.deleteLater()
to the function called when the 'Finished QPushButton
is clicked, but I am struggling to see how to do this in the first case.
Solution
You can set an attribute on the widget to do this:
class Widget(QtGui.QWidget)
def __init__(self, parent=None)
super(Widget, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Your "Finished" button then only has to call self.close()
(which is equivalent to clicking the titlebar close button).
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.