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)
            self.btn.clicked.connect(self.showdialog)
    
        def showdialog(self):
            dialog = QDialog(parent=self)
            btn = QPushButton('ok', dialog)
            btn.move(50, 50)
            dialog.setWindowTitle("Dialog")
    
            flags = dialog.windowFlags()
            flags |= Qt.CustomizeWindowHint
            flags |= Qt.WindowTitleHint
            flags |= Qt.WindowSystemMenuHint
            flags |= Qt.WindowCloseButtonHint
            flags |= Qt.WindowStaysOnTopHint
            flags |= Qt.WindowMaximizeButtonHint
            dialog.setWindowFlags(flags)
    
            dialog.showMaximized()
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        demo = DialogDemo()
        demo.show()
        sys.exit(app.exec_())
    

Log in to reply
 

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