PyQt - How to check is QDialog is visible?

golobitch picture golobitch · Dec 13, 2012 · Viewed 9.5k times · Source

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.

Answer

Achayan picture Achayan · Dec 13, 2012

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