我有两个窗口,我想使用Qt计时器在三秒钟后将其隐藏,但是它的重叠部分……可能是在窗口大小设置为 “ showMaximized”
from PyQt4 import QtCore, QtGui
from PyQt4 import QtGui
from PyQt4.QtCore import Qt, QPoint
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.showMaximized()
Form.setStyleSheet(_fromUtf8("background-color: rgb(0, 0, 0);"))
self.label = QtGui.QLabel(Form)
self.label.setGeometry(QtCore.QRect(450, 317, 300, 61))
self.label.setStyleSheet(_fromUtf8("font: 75 60pt \"Tlwg Mono\";color: rgb(255, 255, 255);"))
self.label.setObjectName(_fromUtf8("label"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.label.setText(_translate("Form", "omniOS", None))
class Ui_Dialog1(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.showMaximized()
Dialog.setStyleSheet(_fromUtf8("background-color: rgb(0, 0, 0);"))
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.centralwidget = QtGui.QWidget(Dialog)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
class Dialog(QtGui.QDialog, Ui_Form):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.setupUi(self)
class Dialog1(QtGui.QDialog, Ui_Dialog1):
def __init__(self, parent=None):
super(Dialog1, self).__init__(parent)
self.setupUi(self)
def paintEvent(self, event):
painter = QtGui.QPainter(self)
painter.setPen(QtGui.QPen(QtCore.Qt.white))
painter.drawArc(QtCore.QRectF(640, 330, 35, 35), 0, 5750)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
w1=Dialog()
w2=Dialog1()
def on_timeout():
w1.hide()
w2.show()
QtCore.QTimer.singleShot(3000, on_timeout)
sys.exit(app.exec_())
我需要做的是,我需要得到 三秒钟后的第二个窗口 尺寸设置为最大化。
Form.showMaximized()
此更改为(form.resize)其预期的工作。 有帮助吗
答案 0 :(得分:2)
您不会观察到由于w2在w1之上而关闭了w1,但是如果它在工作,那么您在注释中指出我了解到您最初只希望看到w1并在3秒钟后显示w2并隐藏w1 ,考虑到解决方案如下:
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
w1=Dialog()
w2=Dialog1()
w2.hide()
QtCore.QTimer.singleShot(3000, w1.hide)
QtCore.QTimer.singleShot(3000, w2.showMaximized)
sys.exit(app.exec_())