简体   繁体   English

PyQt - 如何检查QDialog是否可见?

[英]PyQt - How to check is QDialog is visible?

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. 所以,当我说Ball()时,这将在QDialog上画一个球。 And then when this is done, I am moving the balls around QDialog in an infinite loop. 然后当这个完成时,我在无限循环中围绕QDialog移动球。 I want to say something like while QDialog.isVisible() move them around . 我想说的是, QDialog.isVisible()移动它们时

I don't have any parent dialog or form or any child dialog or form. 我没有任何父对话框或表单或任何子对话框或表单。 It's all just about this QDialog . 这就是这个QDialog I know that it's stupid to do with QDialog , but I am not allowed to use anything else than just QDialog . 我知道,这是愚蠢的与做的QDialog ,但我不能使用别的不仅仅是QDialog

You can use isVisible from QWidget because QDialog basically inherits QWidget. 您可以使用QWidget中的isVisible,因为QDialog基本上继承了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 有关详细信息,请访问http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.html#isV​​isible

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM