Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MainWindow inside MainWindow
Qt 6.11 is out! See what's new in the release blog

MainWindow inside MainWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 412 Views 2 Watching
  • 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 Offline
    T Offline
    thomasGl
    wrote on last edited by
    #1

    Hey guys. How can i put a Mainwindows inside a Mainwindow. Is this possible? 1.png

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QMainWindow *mainWindow = new QMainWindow;
        QMainWindow *subWindow = new QMainWindow(mainWindow);
        mainWindow->setCentralWidget(subWindow);
        subWindow->setWindowFlags(Qt::Widget);
        mainWindow->show();
    
        return a.exec();
    }
    
    
    Pl45m4P Z 2 Replies Last reply
    0
    • T thomasGl

      Hey guys. How can i put a Mainwindows inside a Mainwindow. Is this possible? 1.png

      #include "mainwindow.h"
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QMainWindow *mainWindow = new QMainWindow;
          QMainWindow *subWindow = new QMainWindow(mainWindow);
          mainWindow->setCentralWidget(subWindow);
          subWindow->setWindowFlags(Qt::Widget);
          mainWindow->show();
      
          return a.exec();
      }
      
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @thomasGl said in MainWindow inside MainWindow:

      Hey guys. How can i put a Mainwindows inside a Mainwindow. Is this possible?

      In general, yes, but why do you think you need it?
      QMainWindow is just a QWidget class with some status bars and menus after all...
      In most cases where people think they need two QMainWindows , a normal QWidget or any other design is better/fine.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      3
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #3

        Never seen a use case for that. And it’s risky business, especially when floating dock widgets come into play.

        Software Engineer
        The Qt Company, Oslo

        1 Reply Last reply
        3
        • T thomasGl

          Hey guys. How can i put a Mainwindows inside a Mainwindow. Is this possible? 1.png

          #include "mainwindow.h"
          #include <QApplication>
          
          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
              QMainWindow *mainWindow = new QMainWindow;
              QMainWindow *subWindow = new QMainWindow(mainWindow);
              mainWindow->setCentralWidget(subWindow);
              subWindow->setWindowFlags(Qt::Widget);
              mainWindow->show();
          
              return a.exec();
          }
          
          
          Z Offline
          Z Offline
          zeljko
          wrote on last edited by
          #4

          @thomasGl Sure, use MDI windows.

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved