Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Read Data From URL
Qt 6.12 LTS is out! See what's new in the release blog

Read Data From URL

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 3 Posters 4.4k Views
  • 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.
  • jsulmJ jsulm

    @Ketan__Patel__0011 Yes

    Ketan__Patel__0011K Offline
    Ketan__Patel__0011K Offline
    Ketan__Patel__0011
    wrote on last edited by Ketan__Patel__0011
    #9

    @jsulm
    I am remove this line event.exec(); from my code And make QNetworkAccessManager manager; variable as a class member
    but still i didn't the the response.

    jsulmJ 1 Reply Last reply
    0
    • Ketan__Patel__0011K Ketan__Patel__0011

      @jsulm
      I am remove this line event.exec(); from my code And make QNetworkAccessManager manager; variable as a class member
      but still i didn't the the response.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #10

      @Ketan__Patel__0011 Do you mean finished signal was not emitted?
      You should add error handling to your code.
      And you CAN'T read the response just after sending the request, do it in a slot connected to finished signal...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Ketan__Patel__0011K 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Ketan__Patel__0011 Do you mean finished signal was not emitted?
        You should add error handling to your code.
        And you CAN'T read the response just after sending the request, do it in a slot connected to finished signal...

        Ketan__Patel__0011K Offline
        Ketan__Patel__0011K Offline
        Ketan__Patel__0011
        wrote on last edited by
        #11

        @jsulm

        response->errorString() function give me this error message
        Error Is : Unknown error

        jsulmJ 1 Reply Last reply
        0
        • Ketan__Patel__0011K Ketan__Patel__0011

          @jsulm

          response->errorString() function give me this error message
          Error Is : Unknown error

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #12

          @Ketan__Patel__0011 As I said: you can't read response just after sending request. This is not how asynchronous APIs work. Read response in a slot connected ti finished signal. This is also what @JonB already wrote.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Ketan__Patel__0011K 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Ketan__Patel__0011 As I said: you can't read response just after sending request. This is not how asynchronous APIs work. Read response in a slot connected ti finished signal. This is also what @JonB already wrote.

            Ketan__Patel__0011K Offline
            Ketan__Patel__0011K Offline
            Ketan__Patel__0011
            wrote on last edited by
            #13

            @jsulm

            Thanks For Reply

            So Do you have any Suggestion or Any Sample Code Or Any Block Of Code For it

            jsulmJ 1 Reply Last reply
            0
            • Ketan__Patel__0011K Ketan__Patel__0011

              @jsulm

              Thanks For Reply

              So Do you have any Suggestion or Any Sample Code Or Any Block Of Code For it

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #14

              @Ketan__Patel__0011 Did you read the documentation? https://doc.qt.io/qt-5/qnetworkaccessmanager.html

              QNetworkAccessManager *manager = new QNetworkAccessManager(this);
              connect(manager, &QNetworkAccessManager::finished,
                      this, &MyClass::replyFinished);
              
              manager->get(QNetworkRequest(QUrl("http://qt-project.org")));
              

              In MyClass::replyFinished you read the response.

              And there are many examples: https://doc.qt.io/qt-5/examples-network.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              Ketan__Patel__0011K 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Ketan__Patel__0011 Did you read the documentation? https://doc.qt.io/qt-5/qnetworkaccessmanager.html

                QNetworkAccessManager *manager = new QNetworkAccessManager(this);
                connect(manager, &QNetworkAccessManager::finished,
                        this, &MyClass::replyFinished);
                
                manager->get(QNetworkRequest(QUrl("http://qt-project.org")));
                

                In MyClass::replyFinished you read the response.

                And there are many examples: https://doc.qt.io/qt-5/examples-network.html

                Ketan__Patel__0011K Offline
                Ketan__Patel__0011K Offline
                Ketan__Patel__0011
                wrote on last edited by
                #15

                @jsulm

                Thanks for the reply

                I am try all are the solution

                And Create One Small QWidget Application Example For it and my problem is solved but..
                i am create one library in Qt any put my same code in my Class library functions
                that time i didn't get the response from my URL.

                jsulmJ 1 Reply Last reply
                0
                • Ketan__Patel__0011K Ketan__Patel__0011

                  @jsulm

                  Thanks for the reply

                  I am try all are the solution

                  And Create One Small QWidget Application Example For it and my problem is solved but..
                  i am create one library in Qt any put my same code in my Class library functions
                  that time i didn't get the response from my URL.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #16

                  @Ketan__Patel__0011 In what app do you use that library? Does that app have a running Qt event loop?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Ketan__Patel__0011K 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Ketan__Patel__0011 In what app do you use that library? Does that app have a running Qt event loop?

                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011
                    wrote on last edited by
                    #17

                    @jsulm

                    Actually i am create My Library in QT And i am export The Some Function From My Library and used in others application (DLLImport And DLLExport)

                    jsulmJ 1 Reply Last reply
                    0
                    • Ketan__Patel__0011K Ketan__Patel__0011

                      @jsulm

                      Actually i am create My Library in QT And i am export The Some Function From My Library and used in others application (DLLImport And DLLExport)

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #18

                      @Ketan__Patel__0011 But does this application have a Qt event loop?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      Ketan__Patel__0011K 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @Ketan__Patel__0011 But does this application have a Qt event loop?

                        Ketan__Patel__0011K Offline
                        Ketan__Patel__0011K Offline
                        Ketan__Patel__0011
                        wrote on last edited by
                        #19

                        @jsulm
                        No that Application is not Qt Based But My Library Is Qt Based

                        jsulmJ 1 Reply Last reply
                        0
                        • Ketan__Patel__0011K Ketan__Patel__0011

                          @jsulm
                          No that Application is not Qt Based But My Library Is Qt Based

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #20

                          @Ketan__Patel__0011 said in Read Data From URL:

                          But My Library Is Qt Based

                          That is clear. But without Qt event loop Qt networking isn't going to work. You could execute networking part (from your DLL) in a thread with Qt event loop.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          3

                          • Login

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