if you are just trying to capture the close event from a user clicking the 'x' button then
def closeEvent(self, event):
print ("inside the close")
def closeEvent(self, event):
print ("inside the close")
To copy to clipboard, switch view to plain text mode
is going to work, it'll run through whatever you've got there, but the window is still going to close on you. You are just intercepting it before it actually closes.
if you need to ask if they really want to close, then you need to interrupt that event being passed in.
so more like:
def closeEvent(self, event):
if checkstatement is True: #(don't really want to close the window
event.ignore()
else:
print ("really closing for real this time!")
def closeEvent(self, event):
if checkstatement is True: #(don't really want to close the window
event.ignore()
else:
print ("really closing for real this time!")
To copy to clipboard, switch view to plain text mode
as for connecting your actions to the close event, I typically just connect it the action to self.close as it will also call the closeEvent()
Hope that helps.
Bookmarks