Results 1 to 4 of 4

Thread: Loading in sync

  1. #1
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Arrow Loading in sync

    Hi,
    I am writing an application which requires me to download certain images from certain servers.
    As this happens very frequently, the usage of signal and slots will make the gui get highcup.

    So the question is:

    How can I make download in snyc within a thread, without an exec() loop (or even with if there is no other way) like this (which does not work though):

    Qt Code:
    1. QNetworkAccessManager net;
    2. QNetworkReply *re (net.get( QNetworkRequest( QUrl( Qstring("www.blah.org/key") ) ) ));
    3. if (re->waitForReadyRead(-1)) //! @bug this does not work as supposed, waitForRead returns false and returns INSTANTLY!!
    4. qDebug() << "ReadyRead yeha!!!";
    5. if (re->error()) {
    6. qDebug() << "Can't download" << re->url().toString()
    7. << ":" << re->errorString();
    8. } else {
    9. img->load(re->readAll());
    10. qDebug() << "Savin IMG";
    11. }
    12. delete re;
    To copy to clipboard, switch view to plain text mode 

    Thx for any reply.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading in sync

    Have you seen the article on [wiki]Keeping the GUI Responsive[/wiki]?

    BTW. If your waitForReadyRead() fails, there has to be a reason for it... Probably it's not supported by QNetworkReply.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Loading in sync

    This article confirms what I somewhat feared. Thank you.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading in sync

    What did you fear exactly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QSplashScreen loading icon
    By talk2amulya in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2009, 09:46
  2. [Qt3] Two QListviews - VerticalScrollBar Sync Problems
    By BrainB0ne in forum Qt Programming
    Replies: 0
    Last Post: 25th September 2008, 11:18
  3. Replies: 1
    Last Post: 28th August 2008, 21:18
  4. QImage not loading successively.
    By node_ex in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2008, 13:20
  5. QSA: loading scripts at runtime
    By seneca in forum Qt Programming
    Replies: 0
    Last Post: 15th February 2006, 15:19

Tags for this Thread

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.