I am embedding an application within a tab in a pyqt QApplication. When I close the tab this application is embedded in how do I allow it to display the "Save your changes" dialog?
I use this on tab_close:
win32gui.PostMessage(int(wdg.process._handle),win32con.WM_CLOSE,0,0)
When I do this though, I lose this dialog box, if the application would normally throw one up.
The code looks similar to this:
class MainWindow(QTabWidget):
def __init__(self, parent=None):
QTabWidget.__init__(self, parent)
self.setTabsClosable(1)
self.tabCloseRequested.connect(self.close_tab)
...
def close_tab(self,ind):
wdg = self.widget(ind)
win32gui.PostMessage(int(wdg.process._handle),win32con.WM_CLOSE,0,0)
self.removeTab(ind)
del wdg
...
This produces a UI like this (with Window's notepad.exe embedded). Clicking the "X" on the tab will close Notepad without prompting the user to save any input.
How can I close the tab and allow the embedded application to prompt a user to save their changes?