Important: Please read the Qt Code of Conduct -

How to add a maximize button in dialog title bar, which is a child of another widget ?

  • code: (it is ok in MS windows, but no Maximize button in linux)

    import sys
    from PyQt5.QtGui import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtCore import *
    class DialogDemo(QMainWindow):
        def __init__(self, parent=None):
            super(DialogDemo, self).__init__(parent)
            self.setWindowTitle('Main Window')
            self.resize(350, 300)
            self.btn = QPushButton(self)
            self.btn.setText('Popup Dialog')
            self.btn.move(50, 50)
        def showdialog(self):
            dialog = QDialog(parent=self)
            btn = QPushButton('ok', dialog)
            btn.move(50, 50)
            flags = dialog.windowFlags()
            flags |= Qt.CustomizeWindowHint
            flags |= Qt.WindowTitleHint
            flags |= Qt.WindowSystemMenuHint
            flags |= Qt.WindowCloseButtonHint
            flags |= Qt.WindowStaysOnTopHint
            flags |= Qt.WindowMaximizeButtonHint
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        demo = DialogDemo()

Log in to reply