Results 1 to 8 of 8

Thread: Resize MDI subwindows

  1. #1
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Resize MDI subwindows

    Hi,

    I want to resize subwindows of simple MDI application:
    Qt Code:
    1. #include "MainWindow.h"
    2. #include "ui_MainWindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10. m_firstWindow = new FirstWindow;
    11. m_secondWindow = new SecondWindow;
    12. m_thirdWindow = new ThirdWindow;
    13.  
    14. m_firstWindow->resize( 500, 500 );
    15.  
    16. ui->mdiArea->addSubWindow( m_firstWindow );
    17. ui->mdiArea->addSubWindow( m_secondWindow );
    18. ui->mdiArea->addSubWindow( m_thirdWindow );
    19. }
    20.  
    21. MainWindow::~MainWindow()
    22. {
    23. delete ui;
    24. }
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work:
    280.png

    It is the project: https://github.com/8Observer8/SimpleMDIApplication

    Thank you!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Resize MDI subwindows

    If you want to resize the MdiSubWindow then you should call resize() on that object, not the widget it contains:
    Qt Code:
    1. #include "MainWindow.h"
    2. #include "ui_MainWindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10. m_firstWindow = new FirstWindow;
    11. m_secondWindow = new SecondWindow;
    12. m_thirdWindow = new ThirdWindow;
    13.  
    14. QMdiSubWindow *w1 = ui->mdiArea->addSubWindow( m_firstWindow );
    15. ui->mdiArea->addSubWindow( m_secondWindow );
    16. ui->mdiArea->addSubWindow( m_thirdWindow );
    17.  
    18. w1->resize( 500, 500 );
    19. }
    To copy to clipboard, switch view to plain text mode 

    If your widgets actually contained anything then the containing QMdiSubWindow would get a preferred size from the layout and you probably would not need to resize at all.

  3. The following user says thank you to ChrisW67 for this useful post:

    8Observer8 (17th August 2014)

  4. #3
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Resize MDI subwindows

    Thank you very much

  5. #4
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Resize MDI subwindows

    I've created my first useful MDI application

    Matrix Operations

    282.jpg

    Source code: https://github.com/8Observer8/MatrixOperations

  6. #5
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Resize MDI subwindows

    When I run my MDI application I see:
    283.png

    But I want to see:
    284.png

    Source code: https://github.com/8Observer8/SingleTriangleEditor

    How will I be able to do it? Where can I read about layout the MdiSubWindows on the mdiArea?

    Thank you!

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Resize MDI subwindows

    MDI sub windows are basically like windows, they are not layouted among themselved other than the simple things that QMdiArea::WindowOrder does.

    Which is one of the reasons why this sort of MDI applications is not used very often anymore.

    Cheers,
    _

  8. The following user says thank you to anda_skoa for this useful post:

    8Observer8 (20th August 2014)

  9. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Resize MDI subwindows

    There are also tileSubwindows() and cascadeSubWindows() slots to arrange the windows. If you want a layout that is generally fixed then you are better off doing that yourself with a layout inside a widget rather than with QMdiArea.

  10. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Resize MDI subwindows

    Agreed.
    The screenshot does not look like multiple documents at all, more like a single document and editing tool.

    Which would more likely be served better by using QDockWidget

    Cheers,
    _

Similar Threads

  1. QMdiArea Problems with Menu Bar when subWindows are maximized
    By BettaUseYoNikes in forum Qt Programming
    Replies: 1
    Last Post: 6th July 2021, 06:17
  2. subwindows in application - memory usage
    By Tomasz in forum Newbie
    Replies: 6
    Last Post: 23rd July 2010, 09:13
  3. Replies: 5
    Last Post: 15th June 2010, 22:32
  4. display order of subwindows in mdi area
    By eric_vi in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2010, 17:05
  5. QMainWindow...button in subwindows
    By Peppy in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2009, 16:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.