How do I implement a "maximized" layout strategy for QMdiArea?
-
Hello!
I have recently started a small learning project where I am using an QMdiArea as the central widget. This widget is also given a subwindow in the form of a QGlWidget. I would like that this subwindow is initialized as maximised when I start the application. So far I have not succeded and since I have not managed find anyone else asking this question it must be easily solvable. :-)According to the QMdiArea documentation I can see that there are two built in layout strategies: Tiled and cascaded. None of these suite my need. I would like to use a third: Maximized.
Obviously this is something that can be implemented since I have seen applications built on Qt acting this way. Can someone tell me how to go about solving my problem? I have tried to use the showMaximized member function on the subwindow but it has no effect.
I am working on a Linux box running OpenSUSE 13.2 (KDE Desktop) and linking to Qt 4.8.6.
-
Hi and welcome to devnet,
Wouldn't showMaximized do what you want ?
-
@SGaist Thank you!
The problem is that the showMaximized member function (i am calling it from the main function) does not have an effect when I am calling it. Maybe this is due to the fact that I am running on X11. The documentation mentions that "On X11, this function may not work properly with certain window managers. See the Window Geometry documentation for an explanation."
However the additional information under Window Geometry did not provide any solution to me. -
One thing you can try is to set the geometry of the client to match the one of QMdiArea
-
@SGaist Thank you for your help! I have now solved the problem!
The thing was that I tried to maximize the widget of the QMdiSubWindow instead of maximizing the QMdiSubWindow itself! So by using the following code it now works (MainWindow inherits QMdiArea and Viewer inherits QGLWidget):
// Create main window MainWindow* w = new MainWindow; // create viewer widget and add it to the main window Viewer* v = new Viewer; w->addSubWindow(v); // get subwindow QMdiSubWindow* sw = w->currentSubWindow(); // maximize sub window sw->showMaximized(); // show main window w->show();
-
Didn't thought of that one :)
Glad you found out !
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)