resize mdiArea with Mainwindow
-
I have a Main Window with an top dock.
In design mode i added an mdiArea.on main.cpp i maximize my windown with : w.showFullScreen();
I now want the mdiArea to be also fullscreen under the top dock.
I tried lots of different solutions, but i dont get the mdiArea to scale with the size of the mainwindow
--sorry for my crappy english
-
Hi and welcome to devnet,
Did you set your mdiArea as central widget of QMainWindow ?
-
Yes i set the mdiArea as centralWidget
here is the full code of my main.cpp :
[code]
int main(int argc, char *argv[])
{
QApplication a(argc, argv);MainWindow w; w.showFullScreen(); QMdiArea *mdiArea =w.findChild<QMdiArea*>("mdiArea"); w.setCentralWidget(mdiArea); w.show(); return a.exec();
}
[/code]
-
Why are you setting it like this ? You should do it directly in MainWindow's constructor
-
Because i'm new to QT and don't now how to do it proper.
Could you give me an example on how to do this ?
-
Just take a look at QMainWindow's documentation and the MainWindow Application Example
-
Is the mdiArea empty ?
-
If empty means, that ther is no mdi window inside, then yes.
the program should start with an empty full screen mid area and then all needed windows should be chosen with the menu
-
Can you show your MainWindow constructor ?
-
Als elements has been created with the designer
This is my Mainwindow.ccp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QApplication> #include <QMdiSubWindow> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //showMaximized(); showFullScreen(); setCentralWidget(ui->mdiArea); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_actionBeenden_triggered() { QApplication::quit(); }
and this is the Mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT void createChild(); public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_actionBeenden_triggered(); void on_actionFader_triggered(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
[edit: Fixed coding tags, use three backticks SGaist]
-
In that case, why don't you put the mdiArea directly as central widget with designer ?
-
I have the auto created QWidget , auto named central widget.
For this i have selected vertical layout.Below the QWidget i have the mdiArea.
How can i change this ?
Or is that correct ? -
Add mdiArea to the vertical layout and you should be good to go.
-
I think that is what i done, but it still desn't work
-
So what you want is to put all layout margins at 0 so your mdiArea widget will take the whole place
-
I have done that, but the mdi area still does not scale out
-
The question is going to be silly but did you just put it over the QMainWindow or did you explicitly clicked the layout vertically menu entry ?
-
i clicked the vertical layout manualy on the central widget.
Also i cant put the mdi area over it. -
What do you mean by you can't put the mdi area over it ?
5/24