QMdiSubWindow Buttons Merged With Menubar



  • My setup:
    PyQt 5.9
    Python 3.6.3
    Ubuntu 17.10

    I'm not sure if this is expected behavior, or if I've made a mistake in my code. The following code gives me a result that doesn't seem intuitive. The minimize/maximize/close buttons for the QMdiSubWindows end up merged into the menubar area.

    import sys
    from PyQt5.QtCore import Qt
    from PyQt5.QtWidgets import QApplication, QMainWindow, QMdiArea, QMdiSubWindow, QPlainTextEdit
    
    class TestApp(QMainWindow):
        def __init__(self):
            super(TestApp, self).__init__()
    
            self.initUI()
    
        def initUI(self):
            self.mdiArea = QMdiArea()
            self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
            self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
            self.setCentralWidget(self.mdiArea)
            # self.mdiArea.setViewMode(QMdiArea.TabbedView)
    
            self.setWindowTitle('Test App')
            self.statusBar().showMessage('Ready')
    
            self.menubar = self.menuBar()
            self.fileMenu = self.menubar.addMenu('&File')
    
            # self.toolbar = self.addToolBar('Main Tools')
            # self.toolbar.addWidget(logoLabel)
    
            self.showMaximized()
    
            subWin = QMdiSubWindow()
            child = QPlainTextEdit(self)
            subWin.setWidget(child)
            self.mdiArea.addSubWindow(subWin)
            subWin.setWindowState(Qt.WindowMaximized)
    
            subWin2 = QMdiSubWindow()
            child2 = QPlainTextEdit(self)
            subWin2.setWidget(child2)
            self.mdiArea.addSubWindow(subWin2)
            subWin2.setWindowState(Qt.WindowMaximized)
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        testApp = TestApp()
    
        sys.exit(app.exec_())
    
    

    This is the result I get.
    0_1513911605742_Ubuntu_17-10_PyQt5.png
    Here's what I would expect (positioning and sizing the window manually).
    0_1513911776885_Screenshot_2017-12-21_22-02-42.png
    Is there something wrong with my code, or is there a setting for the MdiArea to keep the subwindow buttons from running into the menubar area?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It might very well be a Ubuntu specific behaviour, can you recheck that with another window manager than Unity ?



  • @SGaist Thanks for the reply. It has the same behavior in the MATE desktop environment. So far I've also tried in Unity and Gnome 3.0 as well.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.