tags:

views:

51

answers:

1

Hello everyone,

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 pressing [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!

+1  A: 

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.

Stephen Chu