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. [SOLVED] QNetworkAccessManager get
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QNetworkAccessManager get

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 4.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.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    I just want to send a value and change it on the website.
    Is this possible

    @ QNetworkAccessManager manager;
    QNetworkRequest request;
    request.setUrl(QUrl(QString("http://...--/forms.htm") + QString("?") + QString("m_dNominalVA=90000")));
    reply= manager.get(request);
    @

    I don't get an error. but it doesn't change the value on the page.

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

      I thought that QNetworkAccessManager::get was used to read something from a url, not the opposite...

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on last edited by
        #3

        Seems right, could it be the constructed URL has a wrong parameter? What if you use it in a web browser? Does your web page support the GET method?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toho71
          wrote on last edited by
          #4

          Yes it does.
          And the value changes.
          I'm trying to debug on the web side and see what the value is .

          1 Reply Last reply
          0
          • T Offline
            T Offline
            toho71
            wrote on last edited by
            #5

            Here is the solution of this problem.
            First
            @void Start::sendStartValues()
            {
            QNetworkAccessManager manager = new QNetworkAccessManager(this);
            setUrl("http://
            --...*/forms.htm" + QString("?") + QString("m_dNominalVA=95000"),manager);
            }@

            And I tried to do like this and it worked.
            @
            void Start::setUrl( const QString& url, QNetworkAccessManager *manager )
            {
            reply = manager -> get( QNetworkRequest( QUrl( url ) ) );
            connect( reply, SIGNAL( finished() ), this, SLOT( replyFinished()) );
            }@

            maybe there is an other solution to this but I dont know how.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fluca1978
              wrote on last edited by
              #6

              I don't see the difference, apart the wrapping method code. The only thing new is the connection of the finished signal. Is that the solution?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                toho71
                wrote on last edited by
                #7

                Nope I had that before and yes I don't see the diffrent solution that made this work either but know it works.
                Maybe this is the diffrence
                @QNetworkAccessManager *manager = new QNetworkAccessManager(this);@

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

                  As you gave no complete code in your first post, this is much likely to be the problem. If you put that into a method, manager->get() returns immediately, the method ends, the stack variable is deleted. That's how C++ works, no Qt magic.

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

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    toho71
                    wrote on last edited by
                    #9

                    Yes
                    To much java and vb and no c++ expert.
                    well I try to learn and this forum is very helpful.

                    Thanks

                    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