How to create a modal window in pyqt?

荒凉一梦 提交于 2019-11-28 13:40:20

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!