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. HTTP POST with Qt 5.1.1

HTTP POST with Qt 5.1.1

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k 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.
  • N Offline
    N Offline
    NomadScarecrow
    wrote on last edited by
    #1

    Hi...

    I'm porting code from Qt 4.8 to 5.1.1, but I'm a little confuse porting this code.

    I have something like this:

    @
    ...
    QUrl url = QUrl("www.something.com/some_file.php");
    QNetworkRequest network_request(url);
    ...
    QUrl request_parameters;

    request_parameters.addQueryItem("key1", QUrl::toPercentEncoding("value1"));
    request_parameters.addQueryItem("key2", QUrl::toPercentEncoding("value2"));
    request_parameters.addQueryItem("key3", QUrl::toPercentEncoding("value3"));
    ...
    QNetworkReply * network_reply = manager.post(network_request, request_parameters.encodedQuery());
    ...
    @

    How I port this code to 5.1.1 since addQueryItem is not a member of QUrl anymore?

    Ok... several people has the same problem, the solution they found, apparently is to use QUrlQuery for the parameters.

    So, in a similar way:

    @
    QUrlQuery request_parameters;

    request_parameters.addQueryItem("key1", QUrl::toPercentEncoding("value1"));
    request_parameters.addQueryItem("key2", QUrl::toPercentEncoding("value2"));
    request_parameters.addQueryItem("key3", QUrl::toPercentEncoding("value3"));
    @

    Is this right?

    After this, how I must call the post method with the new changes?

    Thanks in advance.

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

      see "QUrl::setQuery()":http://qt-project.org/doc/qt-5.0/qtcore/qurl.html#setQuery-2

      --- 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

      • Login

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