Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How do I implement a "maximized" layout strategy for QMdiArea?

    General and Desktop
    qmdiarea layout strategy linux
    2
    6
    2451
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      thuswm last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Wouldn't showMaximized do what you want ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply Reply Quote 0
        • T
          thuswm @SGaist last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by SGaist

            One thing you can try is to set the geometry of the client to match the one of QMdiArea

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            T 1 Reply Last reply Reply Quote 0
            • T
              thuswm @SGaist last edited by

              @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();
              
              
              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post