Results 1 to 2 of 2

Thread: QNetworkAccessManager question

  1. #1
    Join Date
    Mar 2010
    Location
    Capelle aan den IJssel, Netherlands
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Question QNetworkAccessManager question

    Hello,

    I am trying to make a HTTP get request, to a script that has a loop in it and posts data back at certain times.
    For testing, in example, we made a little script, that returns some XML, as in, it gives use the XML header first, and every second after that, it will return a XML tag with some information we like. It does this 5 times, so it takes 5 seconds for the script to end, in this case.

    For the real thing, the script will not end, or will be active for a longer period of time the least.

    The problem is, when I use QNetworkAccessManager, it works fine doing the request and in the finished slot, I get my request data.
    However, what it does, is, it waits the 5 seconds for the whole script to be executed. What I want is, that it first gives me some data, and then, every time some event when there is more data.

    In fact, I would like to receive up to the XML header, and every time there is that delay of a second, a new event I have received data.

    I guess it would be like a motion JPEG thing, where one would keep receiving the new JPEG data, just now, I want to receive XML tags.

    I cannot find any setting, to get this to work, other than that I need to wait for the script to actually end.
    The script works in Firefox, because it adds the XML tags every second until they are all there.

    I hope I make any sense. Can anyone help me on this?

  2. #2
    Join Date
    Mar 2010
    Location
    Capelle aan den IJssel, Netherlands
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: QNetworkAccessManager question

    No one?

    This is the little test code i got, to clarify a bit more:

    Qt Code:
    1. m_httpMan = new QNetworkAccessManager(this);
    2.  
    3. void MainWindow::on_btnURL_clicked()
    4. {
    5. QNetworkRequest request(QUrl(ui->txtURL->text()));
    6.  
    7. m_httpReply = m_httpMan->get(request);
    8.  
    9. connect (m_httpReply, SIGNAL(readyRead()), this, SLOT(on_httpReplyReadyRead()));
    10. connect (m_httpReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(on_downloadProgress(qint64,qint64)));
    11. }
    12.  
    13.  
    14. void MainWindow::on_httpReplyReadyRead()
    15. {
    16. QByteArray newData = m_httpReply->read(2048);
    17. ui->txtReply->appendPlainText("ReadyRead:");
    18. ui->txtReply->appendPlainText(newData);
    19. }
    To copy to clipboard, switch view to plain text mode 

    It's a form with a URL input box. After clicking the btnURL button, I make the request.
    I expected the readyRead signal to be triggered every time I receive some data. Instead, it waits till the whole script has finished and then triggers it with the full data.

    Is there a workaround, so readyRead get's triggered with chunks of data, ie. after an end of line or something?

    Thanks in advance

Similar Threads

  1. QNetworkAccessManager within QThread
    By Tomdarkness in forum Newbie
    Replies: 17
    Last Post: 26th August 2014, 15:12
  2. Problems with QNetworkAccessManager
    By pfid in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2009, 19:51
  3. QNetworkAccessManager doesn't work
    By Floppy in forum Newbie
    Replies: 7
    Last Post: 14th November 2009, 16:32
  4. QNetworkAccessManager or QHttp
    By mind_freak in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2009, 20:24
  5. QNetworkAccessManager vs QHttp
    By jiveaxe in forum Newbie
    Replies: 3
    Last Post: 17th February 2009, 14:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.