I write a simple MDI text editor using Qt 4. When a text window (MyDoc
derived from QTextEdit
) is being closed, I want to know whether it is being closed by pressi开发者_如何转开发ng [X] on that child window or by closing the whole application. Then I will use this info some way (say, I want to issue a message box with an additional question in case of using [X]). How can I achieve this? I don't know a way of distinguishing that in redefined closeEvent()
, which could be the best solution...
Thanks!
Install an event filter on the global instance of QApplication and watch for Close event. It should arrive before the closeEvent() is called on your widget.
精彩评论