Results 1 to 4 of 4

Thread: How to get an image from a web srever ?

  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to get an image from a web srever ?

    Hi,

    I would like to get an image from a web server. The idea is that this image should be buffered , I guess, in a QByteArray.

    Is it a class that already does this ?

    How could that be implemented ?

  2. #2
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get an image from a web srever ?

    Quote Originally Posted by probine View Post
    Hi,

    I would like to get an image from a web server. The idea is that this image should be buffered , I guess, in a QByteArray.

    Is it a class that already does this ?

    How could that be implemented ?
    Where are you stuck?

    Try to combine the approaches of my answers here and here?

    If you know (a little bit) in advance which images you need:
    1) Download them from a server
    2) Create the QIimages from the bytearrays, for example via the QImage::fromData
    3) Insert the image into an QMap<QString, QImage> using whatever key you need
    4) overload the QTextBrowser::loadResource function, for example by creating a new scheme "myPics://key"
    5) use the image
    Last edited by camel; 12th January 2007 at 16:03. Reason: spelling error

  3. #3
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get an image from a web srever ?

    No, that is not what I want.

    I want to be able to get different images who are not predefined.

    for example, I want to get an image from www.google.com, tomorrow an other one from somewhere else... and so on.

    So I need a class that does this.

  4. #4
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get an image from a web srever ?

    Quote Originally Posted by probine View Post
    for example, I want to get an image from www.google.com, tomorrow an other one from somewhere else... and so on.
    Yes, download them via qhttp, put them into the map, use them.

    With the little advance knowledge, I mean:
    Having the time to wait for qhttp to receive the image, since you have to use the asynchronous qhttp api which, I do believe, would not work directly from loadResource...but you might want to try that out.

    (You might also want to try to check out what happens if the, the first time that loadResource is called you return a temp image, then start the download process, and from then on return the right image. But this might be completely undefined behaviour..)

    So I would say QHttp is the class you want...minus the cache stuff...which should not be too hard to build

Similar Threads

  1. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  2. Fast image drawing/scaling in Qt 3.3
    By eriwik in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 10:45
  3. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01

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.