[SOLVED] QNetworkAccessManager get

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

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

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

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

  • Here is the solution of this problem.
    @void Start::sendStartValues()
    QNetworkAccessManager manager = new QNetworkAccessManager(this);
    --...*/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.

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

  • 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);@

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

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


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.