View Full Version : Resize MDI subwindows
8Observer8
16th August 2014, 09:46
Hi,
I want to resize subwindows of simple MDI application:
#include "MainWindow.h"
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_firstWindow = new FirstWindow;
m_secondWindow = new SecondWindow;
m_thirdWindow = new ThirdWindow;
m_firstWindow->resize( 500, 500 );
ui->mdiArea->addSubWindow( m_firstWindow );
ui->mdiArea->addSubWindow( m_secondWindow );
ui->mdiArea->addSubWindow( m_thirdWindow );
}
MainWindow::~MainWindow()
{
delete ui;
}
But it doesn't work:
10559
It is the project: https://github.com/8Observer8/SimpleMDIApplication
Thank you!
ChrisW67
17th August 2014, 04:52
If you want to resize the MdiSubWindow then you should call resize() on that object, not the widget it contains:
#include "MainWindow.h"
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_firstWindow = new FirstWindow;
m_secondWindow = new SecondWindow;
m_thirdWindow = new ThirdWindow;
QMdiSubWindow *w1 = ui->mdiArea->addSubWindow( m_firstWindow );
ui->mdiArea->addSubWindow( m_secondWindow );
ui->mdiArea->addSubWindow( m_thirdWindow );
w1->resize( 500, 500 );
}
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.
8Observer8
17th August 2014, 06:08
Thank you very much :)
8Observer8
19th August 2014, 09:27
I've created my first useful MDI application :D
Matrix Operations
10563
Source code: https://github.com/8Observer8/MatrixOperations
8Observer8
20th August 2014, 05:40
When I run my MDI application I see:
10564
But I want to see:
10565
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!
anda_skoa
20th August 2014, 08:36
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,
_
ChrisW67
20th August 2014, 21:23
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.
anda_skoa
21st August 2014, 09:24
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,
_
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.