PyQt - How to check is QDialog is visible?

2020-07-26 02: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条回答
Deceive 欺骗
2楼-- · 2020-07-26 02:52

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

查看更多
登录 后发表回答