Cant't hide a window when window size maximize

2019-02-16 03:00发布

i have two windows,i want to hide it after three seconds by using Qt timer,but its overlapping...its probably occurs when window size sets to "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_())

what I need to do is, I need to get second window after three seconds when size sets to maximized.

 Form.showMaximized()

This change to (form.resize) its working what i expected. Any help plz

1条回答
Viruses.
2楼-- · 2019-02-16 03:07

You do not observe that w1 is closed because w2 is above w1, but if it is working, so you point out in the comments I understand that you want initially only visible w1 and after 3 seconds w2 is displayed and w1 is hidden, considering that the solution is the following:

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_())
查看更多
登录 后发表回答