开发者

How to resize QMdiArea together with main window?

开发者 https://www.devze.com 2022-12-25 18:00 出处:网络
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 mdiAr

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 mai开发者_开发问答nwindow.ui file?

Thanks!


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.


QMdiSubWindow* w = mdiArea->addSubWindow(new QFontDialog());
w->setWindowFlags(Qt::FramelessWindowHint);
w->showMaximized();
0

精彩评论

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