• Hi all
    I have a problem managing the subwindows in the MdiArea component
    The problem is very simple, when Adding a widget as a subwindow to the MdiArea this doesn't preserve the geometry defined in the designer.
    Sample code:

    @ MyWidget * w=new MyWidget(this);

    So I've tried to play with the geometry like this sample code:

    But I got no success :(
    What I've tried next is to set the geometry in the same block of code where adding the subwindow, in different places but also got no success.

    Is it a bug in the MdiArea??
    Thanks in advance

  • I would do it like this:
    @QMdiSubWindow *w = ui->mdiArea->addSubWindow(new MyWidget());

    Subtle difference there. I'm not sure which class you mean by "this" and what geometry should be preserved? If you want to use fixed geometry, set a fixed size in the designer. Best practice is to almost always use resizable windows (use layouts).

    It is probably not a bug in the MDI area.

  • MDI windows are almost always meant to be resized. So like Franzk says: best is to make sure you handle that case.

    Anyway, what happens if you modify your code like this:
    MyWidget * w=new MyWidget(this);
    QMdiSubWindow* subwindow = ui->mdiArea->addSubWindow(w);

    Note that you will probably need to adjust the size a bit, because the style adds borders. This size will be different per style, so you will have to figure out the adjustment in some dynamic way.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.