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

Injecting custom headers in QtWebEngineView



  • Hello,

    I was wondering if it possible to inject custom headers with QtWebEngineView. I am loading a webview and initial http request should have a custom header. Before upgrading to qt5.7, I would inject them during QNetworkAccessManager.createRequest(). Now, since QNetworkAccessManager can not be attached to QWebEngineView, it's not an option. I've read QtWebEngineView and QtWebPage documentation to see if I could find something relevant, but couldn't find a solution...
    Here are relevant parts of the code:

    void webPage::start()
    {
        m_webView->stop();
        QString m_startUrl = "sample.com"
        m_webView->load(QUrl::fromUserInput(m_startUrl));
        m_webView->show();
    }
    

    I would like to insert a custom header only once when performing
    m_webView->load(QUrl::fromUserInput(m_startUrl));

    Any suggestions are appreciated


  • Moderators



  • Thank you so much! That should do it!


Log in to reply