Resizing according to the mainwidget, how?
Hi to your community, i am new to qt and currently i am working on a project where i have to create a gui. For that reason i chose to use qt which i have to combine it with opencv since i have to work with video processing. To give you an idea how my gui is you can see the following image:
as you can see from the picture my gui is consisted by 3 main widgets, an mdi area which is my central widget as well, a dockwidget area and a frame which contains some push buttons as well for the player.
the buttons inside the frame are fixed through a horizontal layout and then the frame together with the two horizontal spacers is fixed with another horizontal layout. The widgets inside the dockwidget are arranged with a vertical layout and the whole dockwidget area is formed by a grid layout. The mdiarea with the dockwidget plus the spacers with the frame (so, all the upper widgets in the mainwindow) is formed again by a grid layout.
Now that i explain you how my my mainwindow is arranged, lets see what i want to succeed and i can't. When i am starting my program and adding a new subwindow the gui looks like that
which is ok and fair enough to how it is supposed to be, however when i am trying to open a file the main window is not resized properly as you can see from the following image
so i tried to do it by the code. Following also the documentation from "here":http://qt-project.org/doc/qt-4.8/application-windows.html#window-geometry.
Now what i am doing is, for the content of the subwindow i am using opengl in order to show the video. I am specifing the content of the subwindow to be according to the dimensions/resolution of the video file
@viewers.value(title)->setGeometry(viewers.value(title)->geometry().x(), viewers.value(title)->geometry().y(), undistorted_frame.cols, undistorted_frame.rows + 22);
subWindows.value(title)->setGeometry(subWindows.value(title)->geometry().x(), subWindows.value(title)->geometry().x(), viewers.value(title)->frameGeometry().width(), viewers.value(title)->frameGeometry().height());
this code modifies the child widget of the subwindow and the subwindow nicely. However, afterwards i am trying to modify the size of the mdiarea according to the subwindow, and then since i am modifing the mdiarea which is a part of the upper grid layout i was expecting to mainwindow to be resized as well but this does not happen, since what i am getting is the following:
where as you can see that although that the mdiarea follows the size of the subwindow there is a gap between them. The way that i am trying to modify the mdiarea is by just following the same method as i used before in order modify the geometry, so here i am modifing the geometry of the mdiarea according to the child widget which is the subwindow:
@ui->mdiArea->setGeometry(ui->mdiArea->geometry().x(), ui->mdiArea->geometry().y(), subWindows.value(title)->frameGeometry().width(), subWindows.value(title)->frameGeometry().height());@
the point is that in order to manage to fill this gap between the mdiarea and the widget i read that i have to update the layout manually since it does not happening automaticaly.
So, i thought that i should update the geometry of my mdiarea and then update the gridlayout of my main window, and so i did:
but the result is that:
as you can see the mdiarea does not follow the geometry that i am giving to it.
My question is can someone propose me how to make the mainwindow follow and updates the layout as it is supposed to be.
sorry for the long post but i am trying to make more clear what actually i want to do. Any proposal is welcome. As i told i am new to the qt world, and althouhg that i searched the web and tried different things none worked, so i thouhgt that it would more appropriate to ask here since it seems that the most of you are familiar in a more extent level with qt.
try setting the sizepolicy of the mdi area to expanding on both sides.
i have tried, that but not work around...:-(
Why not set the QMdiSubWindow maximised? "showMaximized":http://doc.qt.digia.com/4.7-snapshot/qwidget.html#showMaximized
because i prefer my mdiarea to be resized according to the subwindows and not the vice versa...it should not be so difficult....
the point is that i can make my mdiarea to be resized according to the subwindow/s but the problem is that the mainwindow is not following and be resized according to the central widget which is my mdiarea
I think it is a little odd to have a docked window with captions of a floating window. Not very intuitive. And not very pretty when the actual window captions are in a completely different style. No consistency...
The intended behavior of stock Qt components not always fits the particular custom need. Quite often I end up with regular widgets and implementing the desired UI management behavior manually. At least I always know what happens instead of some mysterious intended behavior I have to dig and wonder why it fails to work the way I expect.
I'd definitely do it manually in your case, it would be neat to have an additional button which minimizes a view to a still visible, but smaller size. If you get rid of this huge caption bar on the top, you can minimize a view while keeping its content visible. And I bet with a QWidget derived view you won't have any problems with scaling.