How to create a modal window in pyqt?

后端 未结 1 1684
旧时难觅i
旧时难觅i 2020-12-11 18:12

I looked into the documentation and i found \'self.setWindowModality(QtCore.Qt.WindowModal)\'.
I added this function to my \'init\' function, but howe

相关标签:
1条回答
  • 2020-12-11 18:45

    QDialog has setModal() as found here.

    As the docs state:

    By default, this property is False and show() pops up the dialog as modeless. Setting this property to true is equivalent to setting QWidget.windowModality to Qt.ApplicationModal.

    As @sebastian noted you could use exec(). However it is better to use exec_() as the one sebastian mentioned is also a python call.

    Example:

    my_dialog = QDialog(self) 
    my_dialog.exec_()  # blocks all other windows until this window is closed.
    

    If this doesn't help please post your code and I will have a look.

    0 讨论(0)
提交回复
热议问题