View Full Version : Subclassing QMdiSubWindow and maximize/minimize problems

25th June 2013, 01:02

I have simple "Main window" application, straight from QtCreator wizard. I added QMdiArea as a center widget.

As a first test I created new Qt Form (using wizard), which inherits from QWidget. I reimplemented sizeHint() to return some reasonable size, like 200x200.
Then I added to MainWindow's constructor few lines, so it looked like:
MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)

Form* f = new Form(this);

I've started the application and it worked as expected. There was the MDI window and I could move it, resize and maximize it.

Now, as a second test I changed Form class to inherit from QMdiSubwindow, instead of QWidget (in both *.h and *.cpp files, but the *.ui file was not changed). I also modified Form constructor, in order to respect the new container for setupUi:
setWidget(new QWidget(this));
I expected that QMdiArea should accept the Form instance now just like before, because the documentation says that I can pass either QMdiSubWindow or any other QWidget to QMdiArea::addSubWindow().

This actually works pretty much okay - Form is being added to MDI area and I can move and resize it, but the problem is I cannot maximize it. When I press "maximize" button on the MDI window, the button stays pushed, never pops up and the window doesn't maximize.

What do I do wrong?