[solved]QWebView - Show HTTP POST request



  • Hi,

    try using QWebView for login into a website (formular with HTTP POST). Test thies:

    POST values
    e_user=Max
    e_pwd=Secret

    @void MainWindow::Button_clicked()
    {
    QByteArray postData("e_user=Max&e_pwd=Secret");
    QNetworkRequest netRequest;
    netRequest.setUrl(QUrl("http://example.com/do_login.php"));
    netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "text/html; charset=UTF-8");

    ui->webView->load(netRequest, QNetworkAccessManager::PostOperation, postData);
    

    }@

    I can't log into the website...

    There is also QNetworkAccessManager's post function... but there i get a pointer of QNetworkReply, don't know how show this at *QWebView *...

    Therefore i needed a little bit help...

    Thank you!

    Boris



  • ARGH!!!

    I found the error ... WRONG "ContentTypeHeader" !!!

    @void MainWindow::Button_clicked()
    {
    QByteArray postData("e_user=Max&e_pwd=Secret");
    QNetworkRequest netRequest;
    netRequest.setUrl(QUrl("http://example.com/do_login.php"));
    netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded; charset=UTF-8");

    ui->webView->load(netRequest, QNetworkAccessManager::PostOperation, postData);
    

    }@

    :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.