Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qhttp Post method Sample Require !
Forum Updated to NodeBB v4.3 + New Features

Qhttp Post method Sample Require !

Scheduled Pinned Locked Moved Mobile and Embedded
25 Posts 8 Posters 19.8k 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
    syedasadalibs03
    wrote on last edited by
    #1

    Hello All
    i am new to Qt I have to sent Requet to Web Serve through Qhttp Post method
    so any one can share the working sample of Qhttp Post

    i want to use for Symbain

    Thanks in Advance

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      Hi,

      just call the post method of QNetworkAccessManager, i.e.

      @
      QNetworkReply * post ( const QNetworkRequest & request, const QByteArray & data )
      @

      passing:

      • a QNetworkRequest built the URL that you wish to contact, without the query part.
      • a QByteArray filled with your request parameters, i.e. "param1=value1&param2=value2& ... "

      It works for Desktop, but it should work for Symbian too.

      Of course you'll get a QNetworkReply, but you'll manage it in the same way as GET method, so you can read some other examples related to QNetworkReply.

      Tony.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tony
        wrote on last edited by
        #3

        Btw, I noticed that you were talking about QHttp, but I don't suggest you to use it, cause it has been deprecated by Qt guys.

        T.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          bq. This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

          You should go with"QNetworkAccessManager":http://doc.qt.nokia.com/4.7/qnetworkaccessmanager.html and it's "post()":http://doc.qt.nokia.com/4.7/qnetworkaccessmanager.html#post-2 method together with "QNetworkRequest":http://doc.qt.nokia.com/4.7/qnetworkrequest.html

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raulgd
            wrote on last edited by
            #5

            Why has QHttp been deprecated? that class is really practical

            Raul Guerrero
            http://jimi.mx

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vsorokin
              wrote on last edited by
              #6

              Raul, no, QNetworkAccessManager look more flexible. Though on first view it seems uncomfortably.

              --
              Vasiliy

              1 Reply Last reply
              0
              • R Offline
                R Offline
                raulgd
                wrote on last edited by
                #7

                You're right, it is more flexible, what I meant by practical is just that, what makes the Qt Framework so cool is not just the functionality, but the fact that the framework feels "natural".

                So the fact that they removed QHttp which made HTTP network access more "natural" or easier to use, they whould have just improved QHttp and keep it easy to use, instead of implementing something new like QNetworkAccessManager and making it harder to use.

                I just hope that they don't make a lot of changes like that, which makes Qt less understandable, and keep it like it is right now, "natural".

                Raul Guerrero
                http://jimi.mx

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  Ok, it's deprecated, but not removed from the libs, so, you still can use it.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    raulgd
                    wrote on last edited by
                    #9

                    Yeah, I can still use it, but being deprecated it's not really a good practice to continue using it.

                    I'll learn about QNetworkAccessManager and hope that things don't get too complicated for simple tasks ;)

                    And in the future there are changes in the API that I think could be done better, that's the great thing about open source and having wikis and forums, people can contribute, give opinions and improvements.

                    Raul Guerrero
                    http://jimi.mx

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      Yes, that's true. And in the end you always can grab the sources and continue to use it yourself.

                      May I ask, what you're doing with QHttp, maybe we can give you a hint to the right direction...

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        raulgd
                        wrote on last edited by
                        #11

                        A SOAP and REST producer/consumer, for producer I need to build an HTTP Server, and for a client I need to be able to post information to the server.
                        It's pretty much a lot of XML/text parsing, and using the HTTP or HTTPS protocol as a transport, for me I felt it was cleaner to use QHttp, because if I want to exchange transports, it sounds more practical to just change QHttp to QFtp to QSomeOtherProtocol, than having to exchange QNetworkAccessManager with QFtp.
                        As I wrote earlier, it's for better readability and to make the code more "natural".

                        Raul Guerrero
                        http://jimi.mx

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          kamalakshantv
                          wrote on last edited by
                          #12

                          [quote author="syedasadalibs03" date="1288798157"]Hello All
                          i am new to Qt I have to sent Requet to Web Serve through Qhttp Post method
                          so any one can share the working sample of Qhttp Post

                          i want to use for Symbain

                          Thanks in Advance[/quote]

                          "This":http://wiki.forum.nokia.com/index.php/CS001431_-_Creating_an_HTTP_network_request_in_Qt wiki article may help you.

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #13

                            [quote author="Raul" date="1291943896"]...for me I felt it was cleaner to use QHttp, because if I want to exchange transports, it sounds more practical to just change QHttp to QFtp to QSomeOtherProtocol, than having to exchange QNetworkAccessManager with QFtp.
                            As I wrote earlier, it's for better readability and to make the code more "natural".[/quote]

                            QNetworkAccessManager does support FTP too; you would only have to change the URLs of your request and not even exchange some classes.

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              raulgd
                              wrote on last edited by
                              #14

                              Ok cool, and is it easy to implement my own protocols? by just implementing my own protocol class would the QNetworkAccessManager know what class to call depending on what you place on the URL?

                              Raul Guerrero
                              http://jimi.mx

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on last edited by
                                #15

                                Implementing your own protocol does need a bit more work (Subclassing QNetworkAccessManager and QNetworkReply). I once did it for your project, and it's not a kind of rocket science :-) I can give you an example if you want.

                                http://www.catb.org/~esr/faqs/smart-questions.html

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  dangelog
                                  wrote on last edited by
                                  #16

                                  [quote author="Raul" date="1292457329"]Ok cool, and is it easy to implement my own protocols? by just implementing my own protocol class would the QNetworkAccessManager know what class to call depending on what you place on the URL?[/quote]

                                  Simply subclass QNetworkAccessManager, override its createRequest[1] method, and in there check the protocol inside the URL: if it's your custom protocol, do whatever you have to do to serve the request and return a custom QNetworkReply subclass. Otherwise simply call the base class implementation.

                                  Remember that QNAM / QNR design is 100% asynchronous, therefore you're not expected to block in any case.

                                  fn1. Quite a strange name, since it actually creates a reply!

                                  Software Engineer
                                  KDAB (UK) Ltd., a KDAB Group company

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on last edited by
                                    #17

                                    [quote author="peppe" date="1292491742"]Remember that QNAM / QNR design is 100% asynchronous, therefore you're not expected to block in any case.[/quote]

                                    As far as I know, it's not forbidden to do a synchronous (blocking) network access there. The UI is only not responsive in that time. And I know that it definitely works with blocking transfers, as that's what we did in our QNetworkReply subclass (although emitting readyRead signal is tricky :-) ).

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      dangelog
                                      wrote on last edited by
                                      #18

                                      Surely you can do that, but that's not what your users expect from QNAM.

                                      Software Engineer
                                      KDAB (UK) Ltd., a KDAB Group company

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on last edited by
                                        #19

                                        It depends on what you do (as almost always in our business :) ). In most cases you are right, but there are a good bunch of situations where synchronous transfer is critical to the application design, e.g. think of (writing) database access, where you must know if it went good or not. HTTP is more than web sites nowadays ;)

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • K Offline
                                          K Offline
                                          KonSchubert
                                          wrote on last edited by
                                          #20

                                          [quote author="Volker" date="1291934071"]Ok, it's deprecated, but not removed from the libs, so, you still can use it.[/quote]

                                          According to Synaptics, I have installed the package libqt4-qt3support. Though, it seems I don't have the QHttp Class, as it is neither found by netbeans, nor by my search funcion or manually.

                                          My aim is to use http://medieninf.de/qmapcontrol/ for embedding a (offline) map in my qt application (Only for Desktop so far.).
                                          It's the best libary I have found, but it's outdated (using QHttp...) and I guess there are better libs. So I am hoping for your ideas.

                                          If QMapControl is really the only package that fits my needs, I will try to replace QHttp by QNetworkAccessManager. But I don't have much experience in programming, so I am afraid of changeing sources.

                                          Hopeing for your Help!
                                          Konstantin

                                          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