Python TypeError:本机Qt信号不可调用

Python TypeError:本机Qt信号不可调用,python,authentication,pyqt4,basic-authentication,qnetworkaccessmanager,Python,Authentication,Pyqt4,Basic Authentication,Qnetworkaccessmanager,我试图向受保护的网页发出请求,因此我试图使用QAuthenticator()的帮助进行身份验证。但是,我得到以下错误: mgr.authenticationRequired(response, auth) TypeError: native Qt signal is not callable 这是我脚本的一部分: def authenticate(self): username = 'user' password = 'pass' url = 'http://someu

我试图向受保护的网页发出请求,因此我试图使用
QAuthenticator()
的帮助进行身份验证。但是,我得到以下错误:

mgr.authenticationRequired(response, auth)
TypeError: native Qt signal is not callable
这是我脚本的一部分:

def authenticate(self):
    username = 'user'
    password = 'pass'
    url = 'http://someurl.com'

    mgr = QNetworkAccessManager(self)

    auth = QAuthenticator()
    auth.setUser(username)
    auth.setPassword(password)

    response = QNetworkRequest()
    response.setUrl(QUrl(url))     

    mgr.authenticationRequired(mgr.get(response), auth)

我在这里做错了什么?

正如错误消息所示,您不能调用PyQt信号。相反,您必须使用
emit()
方法:

mgr.authenticationRequired.emit(mgr.get(response), auth)

你为什么要发出这个信号?我对该协议的理解是,当网络上的服务器需要身份验证时,QNAM将发出该信号。您的程序应该连接到该信号,而不是发出该信号。“连接到此信号的插槽应填充authenticator对象中内容(可通过检查reply对象确定)的凭据。”我可能对您尝试的内容有误解