0

I try to add a minimize button in QDialog, but I get error: AttributeError: type object 'Qt' has no attribute 'WindowMinimizeButtonHint'

class MyWidget(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowFlag(Qt.WindowMinimizeButtonHint)
        self.setWindowTitle("My QDialog")
        self.setGeometry(100, 100, 400, 300)

if __name__ == '__main__':
    app = QApplication([])
    widget = MyWidget()
    widget.show()
    app.exec()
zile wang
  • 13
  • 2

1 Answers1

0

In PyQt6 you can no longer use short-form names for enum members. You have to include the enum name. In this case WindowType

self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint)
mahkitah
  • 562
  • 1
  • 6
  • 19