Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebView. How to make a simple POST request.
Qt 6.11 is out! See what's new in the release blog

QWebView. How to make a simple POST request.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    unmanner
    wrote on last edited by
    #1

    Hello!

    I tried to make a simple POST request using QWebView, but my PHP side saying that it is a GET :(

    My QT code:
    @
    ui->mainWebViewInfoWnd->
    load(QNetworkRequest(QUrl(QString("http://176.111.***.93/info"))),
    QNetworkAccessManager::PostOperation,
    QByteArray("key=value"));@

    My PHP code:
    @<?php
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    echo 'POST :)';
    } else {
    echo 'GET :(';
    }
    ?>@

    As a result in my QWebView frame I got: "GET :("

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      [quote author="unmanner" date="1369230409"]
      @
      ui->mainWebViewInfoWnd->
      load(QNetworkRequest(QUrl(QString("http://176.111.***.93/info"))),
      QNetworkAccessManager::GetOperation,
      QByteArray("key=value"));
      @
      [/quote]

      Well, what do you expect when you load the page explicitly with a GET-Request?!

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • U Offline
        U Offline
        unmanner
        wrote on last edited by
        #3

        Sorry sorry sorry!

        I make a mistake in previous post, I corrected the topic! I used PostOperation constant.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          Try to use "QNetworkAccessManager::PostOperation":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html instead of GetOperation.

          http://anavi.org/

          1 Reply Last reply
          0
          • U Offline
            U Offline
            unmanner
            wrote on last edited by
            #5

            I already use QNetworkAccessManager::PostOperation

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved