开发者

Qt: How to find why QTextEdit is being closed?

开发者 https://www.devze.com 2023-01-02 01:45 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消