Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. [Solved] QNetworkAccessManager createRequest post data
Forum Updated to NodeBB v4.3 + New Features

[Solved] QNetworkAccessManager createRequest post data

Scheduled Pinned Locked Moved Qt WebKit
5 Posts 2 Posters 5.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.
  • S Offline
    S Offline
    siguy
    wrote on last edited by
    #1

    Hi,
    I have over ridden the createRequest function in QNetworkAccessManager but now i want to access the post form data that an html form submits is there any way i can do this. It's the data that is the second parameter in the post functions of QNetworkAccessManager, but i don't see how i can access it from the createRequest function ???
    Any help is much appreciated thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hi,

      • With createRequest() you create a new request where you have to define the type as the first parameter.

      for example;
      @Operation op = QNetworkAccessManager::PostOperation;@

      if you do this, is has the same effect as calling post() on the QNetworkAccessManager object.

      • the second parameter in createRequest() is the first parameter in post() -> QNetworkRequest

      • the third parameter in createRequest() is the second parameter in post() -> QIODevice * data
        in createRequest() this is default to 0 because this data atribute is only used if ther first parameter (Operation op) is defended as PostOperation or PutOperation, others don't use this data object...

      so, you have to put your data inside QIODevice * outgoingData = 0 when creating the request.

      where is our data coming from that you want to access? because if your run the function createRequest(), i suppose that your have the data somewhere, and want them to put in the request instead of trying to get it out ?

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • S Offline
        S Offline
        siguy
        wrote on last edited by
        #3

        ok,
        I have an html form with some fields on it which are submitted when a user presses the submit button. I wish to validate this data in the QNetworkAccessManager. As far as i understand this should be the second parameter in the post function data. post then calls createRequest where my code is however i don't see how i can access the form data from the post function in the createRequest function. ??
        I don't create the request it comes from webkit when the user submits the form.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stevenceuppens
          wrote on last edited by
          #4

          ok,

          I guess that the data is inside the QIODevice * outgoingData parameter...

          What do you receive if you do

          @
          QNetworkReply * MyNetworkAccessManager::createRequest(Operation op,
          const QNetworkRequest & req,
          QIODevice * outgoingData)
          {
          qDebug() << outgoingData->readAll();
          }
          @

          Steven CEUPPENS
          Developer &#x2F; Architect
          Mobile: +32 479 65 93 10

          1 Reply Last reply
          0
          • S Offline
            S Offline
            siguy
            wrote on last edited by
            #5

            Thank you very much thats exactly what i needed to know. the parameters are in the outgoingData QIODevice.

            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