QNetworkAccessManager QWaitCondition

时间:2019-04-02 06:48:00

标签: python pyqt pyqt5

当我使用QNetworkAccessManager时,总是提示“ QWaitCondition:在线程仍在等待时被销毁”

enter image description here

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtNetwork import *

class MainWidget(QWidget):
    clicked = pyqtSignal(int)

    def __init__(self, parent=None):
        super(MainWidget, self).__init__(parent)


        self.m_NetManger = QNetworkAccessManager(parent=self)
        self.m_NetManger.finished.connect(self.on_reply)
        self.m_Reply = self.m_NetManger.get(QNetworkRequest(QUrl("https://www.google.com")))

    def on_reply(self, reply):
        if self.m_Reply.error() == QNetworkReply.NoError:
            print("ok")
        else:
            print("error")

        self.m_Reply.deleteLater()


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    widget = MainWidget()
    widget.show()
    app.exec_()

0 个答案:

没有答案