tags:

views:

556

answers:

2

Hi I'm using the QMdiArea in qt4.4. What I'm doing: If a new project is created, I add a number of subwindows to a QMdiArea. And I'd like to disallow the user to close a subwindow during the runtime. The subwindows should be closed, if the hole application is closed or if a new project is created.

As I have seen in the qt-documentaion, there is no flag to apply this functionality.

How can I do this?

Thanx for your answers.

A: 

Could you sub-class QMdiArea and override the default closeActiveSubWindow/closeAllSubWindows methods to not close the window when user requests it?

Tuminoid
+1  A: 

You'd do this the same as for a top-level window: process and ignore the QCloseEvent it sent. QMdiArea::closeActiveSubWindow/QMdiArea::closeAllSubWindows just call QWidget::close, which sends a closeEvent and confirms that it was accepted before proceeding.

You can process this event by subclassing QMdiSubWindow and reimplementing QWidget::closeEvent, or by using an event filter to intercept it..

puetzk