gpt4 book ai didi

python - 类型错误 : native Qt signal is not callable

转载 作者:行者123 更新时间:2023-11-30 23:43:43 25 4
gpt4 key购买 nike

我正在尝试向 protected 网页发出请求,因此我尝试在 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)

关于python - 类型错误 : native Qt signal is not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10618714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com