TypeError: native Qt signal is not callable

Patrick Pedersen picture Patrick Pedersen · May 16, 2012 · Viewed 8.3k times · Source

I'm trying to make a request to a protected webpage, so therefore I'm trying to authenticate with help from QAuthenticator(). However, I get the following error:

mgr.authenticationRequired(response, auth)
TypeError: native Qt signal is not callable

This is a part of my script:

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)

What am I doing wrong here?

Answer

Ferdinand Beyer picture Ferdinand Beyer · May 16, 2012

As the error message indicates, you cannot call PyQt signals. Instead, you have to use the emit() method:

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