Nominate our 2022 Qt Champions!

QtWebEngine : Load URL with HTTPPost

  • Re: QtWebEngine : Load URL with HTTPPost

    I want a function to request url while posting some data.
    With WebKit, I could use the following:

    With class WebView derived from QtWebView :

    void WebView::loadPostUrl(const QUrl &url, QByteArray postdata)
    m_initialUrl = url;
    QNetworkRequest request = QNetworkRequest(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    load(request, QNetworkAccessManager::PostOperation, postdata);
    Since QtWebEngine does interact with QNetworkAccessManager how can we have the same functionalities with QtWebEngine ?


  • Simply: It seems the .load() function only takes 1 argument (the URL) - how are we supposed to pass POST data array and indicate that it is a POST Operation ?

  • I also recently discovered that I've got to port from QWebPage to QWebEnginePage. The 2 things that I were able to do in prior versions (< 5.6):

    1. Send HTTP Post data via load(QNetworkRequest)
    2. Intercept HTTP responses from the server (via setNetworkAccessManager)

    How can I do those things with QWebEngine? And if I cannot achieve the same functionality what are proper workarounds?

Log in to reply