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. Widgets /WidgetBar above of MenuBar
QtWS25 Last Chance

Widgets /WidgetBar above of MenuBar

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmainwindowmenubarmdiareaindicator
5 Posts 2 Posters 2.9k Views
  • 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.
  • H Offline
    H Offline
    hzdev
    wrote on 5 Apr 2016, 17:35 last edited by
    #1

    Hi,
    I'm looking for a solution to put Widgets above of the QMenuBar.
    I tried

    • use QWidget as root-window
    • add a QVBoxLayout to this widget
    • add a QMainWindow to the layout
    • insert another widget at to the layout index 0, so this widget is on top of the QMainWindow

    It works, but if you put an QMdiArea as centralWidget into the QMainWindow, create some QMdiSubWindows and maximized one of them the behavior is unexpectable:

    The MdiSubWindow maximzed only inside the QMDIArea. It has still it's own titlebar with their controls.
    The controls for maximize, normalize, minimize and close don't get to the menubar of the QMainWindow, because doesn't have the Qt::Window - Flag anymore, because it isn't the root-window.
    see:
    QMdiSubWindowPrivate::setMaximizeMode and
    QMdiSubWindowPrivate::menuBar()

    What else can I do to get widgets above of the QMenuBar?

    Thanks in advance for tips / hints.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Apr 2016, 20:37 last edited by
      #2

      Hi and welcome to devnet,

      Out of curiosity, what are you trying to achieve ? Can you share a picture from that ?

      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
      0
      • H Offline
        H Offline
        hzdev
        wrote on 6 Apr 2016, 15:04 last edited by
        #3

        OK, I'll give you a code example which shows what I mean.

        #include <QApplication>
        #include <QString>
        #include <QLineEdit>
        #include <QMdiArea>
        #include <QPushButton>
        #include <QVBoxLayout>
        #include <QMenu>
        #include <QMenuBar>
        #include <QToolBar>
        #include <QMainWindow>
        
        
        class CWidgetBar : public QWidget
        {
        public:
          CWidgetBar()
          {
            QHBoxLayout* pLayout = new QHBoxLayout(this);
            for (int i = 1; i < 10; i++)
            {
              pLayout->addWidget(new QPushButton(QString("I %1").arg(i)));
            }
            pLayout->addWidget(new QLineEdit("lineedit"));
            pLayout->addStretch();
          }
        };
        
        int main(int argc, char *argv[])
        {
          QApplication a(argc, argv);
          QWidget* pRootWindow = new QWidget();
          QVBoxLayout* pLayout = new QVBoxLayout(pRootWindow);
        
          //WidgetBar with some buttons...
          CWidgetBar* pWidgetBar = new CWidgetBar();
          pLayout->addWidget(pWidgetBar);
        
          //MainWindow with Menubar plus a MDIArea as centralWidget with three mdisubwindows
          QMainWindow* pMainWindow = new QMainWindow();
          QMenu* pMenu = new QMenu("&File");
          pMenu->addAction("&Open");
          QAction* pCloseAction = pMenu->addAction("&Close");
          QMenuBar* pMenuBar = pMainWindow->menuBar();
          pMenuBar->addMenu(pMenu);
          QToolBar* pToolBar = new QToolBar();
          pToolBar->addAction(pCloseAction);
          pMainWindow->addToolBar(pToolBar);
        
          QMdiArea* pMdiAra = new QMdiArea();
          pMainWindow->setCentralWidget(pMdiAra);
          pMdiAra->addSubWindow(new QPushButton("one"));
          pMdiAra->addSubWindow(new QPushButton("two"));
          pMdiAra->addSubWindow(new QPushButton("three"));
          pLayout->addWidget(pMainWindow);
        
          pRootWindow->show();
          return a.exec();
        }
        

        Please maximize one of the mdisubwindows...

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hzdev
          wrote on 6 Apr 2016, 15:36 last edited by
          #4

          Here is the screenshot of the example:
          alt text
          As you can see, the maximized mdisubwindows are maximized only inside the mdiarea still with its own frame and titlebar.

          The expected behavior

          • controls goes to the menubar
          • the title goes to the titlebar of the rootWindow
          • the frame and titlebar of the mdisubwindow disappear
          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 6 Apr 2016, 21:12 last edited by
            #5

            That's not how it works and not something I would expect either.

            The mdi sub-windows will only extend in the mdi area, nothing more.

            The behavior you are looking for, you'll have to implement yourself.

            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
            0

            1/5

            5 Apr 2016, 17:35

            • Login

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