Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MdiArea
Forum Updated to NodeBB v4.3 + New Features

MdiArea

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maherali
    wrote on last edited by
    #1

    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);
    ui->mdiArea->addSubWindow(w);
    w->show();@

    So I've tried to play with the geometry like this sample code:
    @
    setGeometry(geometry().x(),geometry().y(),348,500);
    updateGeometry();
    @

    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

    life is just lines of code

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

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

      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.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        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);
        w->show();
        subwindow->setGeometry(subwindow->geometry().x(),subwindow->geometry().y(),348,500);
        @

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved