Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Set QAuthenticator values in other thread



  • I need set proxy credentials for QNetworkAccessManager.

    @QObject::connect(nam, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
    mainWin, SLOT(onProxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), Qt::QueuedConnection);
    @

    Slot is located in the UI thread, because I need show dialog where user can enter user name and password.
    When signal emmited the code in the slot is executed but there is no authorization on proxy. I'm looking on proxy monitor and see error "Proxy authorization required" for my request but signal proxyAuthenticationRequired not emmited again.

    If I put slot realisation in the same thread with QNetworkAccessManger all ok with return athenticator but I can't open dialog.



  • Solved this trouble

    @QObject::connect(nam, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
    mainWin, SLOT(onProxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), Qt::BlockingQueuedConnection);@

    Change type connection on [[doc:Qt::BlockingQueuedConnection]]


Log in to reply