当我使用QNetworkAccessManager时,总是提示“ QWaitCondition:在线程仍在等待时被销毁”
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_()