PyQt - How to check is QDialog is visible?

余生颓废 提交于 2020-01-01 17:08:12

问题


I have a problem. I have this code:

balls = [Ball() for i in range(1, 10)]

So, when I say Ball() this will draw a ball on QDialog. And then when this is done, I am moving the balls around QDialog in an infinite loop. I want to say something like while QDialog.isVisible() move them around.

I don't have any parent dialog or form or any child dialog or form. It's all just about this QDialog. I know that it's stupid to do with QDialog, but I am not allowed to use anything else than just QDialog.


回答1:


You can use isVisible from QWidget because QDialog basically inherits QWidget. So you should be able to check the visibility.

myDialog = QtGui.QDialog()
isVis = myDialog.isVisible()

For more details http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.html#isVisible



来源:https://stackoverflow.com/questions/13850240/pyqt-how-to-check-is-qdialog-is-visible

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