Results 1 to 5 of 5

Thread: loading pictures from a server

  1. #1
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default loading pictures from a server

    Dear all ,
    I want draw images on screen, but images on server and there is a ethernet connection between, server and client.I tried to u http client program to take pictures but i couldnt achieve this. What do you suggest me ?

  2. #2
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: loading pictures from a server

    Take a look at : QNetworkAccessManager
    Try something like that:

    Qt Code:
    1. QNetworkAccessManager * manager;
    2. QNetworkReply * reply = manager->get(QNetworkRequest(yourFile->url()));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: loading pictures from a server

    Dear Friend,
    I have install my linux, http_fetcher program, and it have a function http_fetch(),
    it loads the file to memory from the server, so i could load the picture to memory, and the last step I tried to paint them to the label. But Qpixmap::loadFromData( ) didnt work. Do you have any suggestion?

    Qt Code:
    1. char *data = NULL;
    2. http_fetch(urlpath,&data)
    3. pixmap.loadFromData((const uchar *)data,sizeof(data));
    To copy to clipboard, switch view to plain text mode 
    Last edited by anafor2004; 24th August 2009 at 09:41.

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: loading pictures from a server

    It seems like this fetch is a blocking function.
    Please check the return value of loadFromData().
    And check the length of image data after fetch to make sure that fetcher is fetching right.

  5. #5
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: loading pictures from a server

    sizeof(data) will always return the size of a pointer. You need to use the return value of http_fetch:
    Qt Code:
    1. int len = http_fetch(urlpath,&data)
    2. pixmap.loadFromData((const uchar *)data, len);
    To copy to clipboard, switch view to plain text mode 
    On another note, using a blocking function in your GUI thread is probably not a good idea.

  6. The following user says thank you to numbat for this useful post:

    anafor2004 (25th August 2009)

Similar Threads

  1. Replies: 3
    Last Post: 29th November 2009, 20:24
  2. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 01:23
  3. How to ping a server ?
    By Nyphel in forum Newbie
    Replies: 2
    Last Post: 23rd April 2007, 11:27
  4. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 14:43
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

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.