tags:

views:

265

answers:

1

Hi! I have created an MDI application (using Qt 4.6) in Qt Creator and added QMdiArea to it. Now if I create new child windows, they created inside the mdiArea. That's completely fine. However, the mdiArea has the fixed size which is neither aligned with the main window, nor changed if the main window resized.

What I'm looking for is the easiest way to:
1) set the initial size of mdiArea to be inherited from the main window, and
2) resize mdiArea automatically when the main window is resized.

If some changes to ui_mainwindow.h should be made, how to prevent Qt Creator from changing it back to 'normal' each time I change mainwindow.ui file?

Thanks!

+1  A: 

From your description, it sounds like you don't have a layout set on your central widget. When you open the Object Inspector, the icon next to the centralwidget (which is the parent of the QMdiArea) should have a vertical or horizontal layout on it.

To fix this, you should not edit the ui_mainwindow.h file. It is auto-generated and your changes will be lost. Instead, open the Object Inspector window. Click on the QMainWindow, then open the Form menu and choose Lay Out Vertically.

David Walthall