Nominate our 2022 Qt Champions!

independent child QMainWindow with pyqt5

  • I have an application in which a parent QMainWindow creates a child
    QMainWindow. In PyQt4 these two windows had independent icons in the
    taskbar (at least on KDE and Windows), and could be minimized/maximized
    independently. In PyQt5 the child window doesn't have an icon in the
    taskbar and cannot be minimized/maximized (fully) independently from the
    parent window. Is there a way to obtain the old behavior that was
    present in PyQt4?

    I have read about primary and secondary windows in Qt5 here:
    but I've been unable to find a solution.

    Thank you for your help.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How are you creating that child widget ?

  • Hi, thanks!

    I call the child QMainWindow from the parent QMainWindow as follows:

    self.responseBox = responseBox(self)

    This is the code initializing the child QMainWindow:

    class responseBox(QMainWindow):
        def __init__(self, parent):
            QMainWindow.__init__(self, parent)
            self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowMaximizeButtonHint)

    The full source code of the application is available online:
    The child main window is created on line 834 here
    and the code initializing it is here

    I'll try to generate a small reproducible example and post it here as soon as I have time.

Log in to reply