Make a window appear on top of another, block access to other windows until button clicked

半城伤御伤魂 提交于 2019-12-12 23:30:29

问题


Python 2.7, PyQt4.8.5

I want to have a main app window and then a second pop up window to display com port settings. This window should always be on top of the parent window until either the ok or the cancel button is clicked; closing the child window. (sort of like a required answer i.e. cant process until you choose the settings from the child window)

Is there a Python Qt command to do this?

Apologies if this has been asked/answered before, my search returned nothing useful.


回答1:


You want a modal dialog. For example:

dialog = QInputDialog()
dialog.exec_()

You can either implement your own dialog widget (by subclassing QDialog) or use one of the several available.



来源:https://stackoverflow.com/questions/8622090/make-a-window-appear-on-top-of-another-block-access-to-other-windows-until-butt

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