Results 1 to 3 of 3

Thread: Download file to QString

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Download file to QString

    Hey all... What is the best way to download a file from HTTP or HTTPS, and turn the contents into a QString for I can manipulate it.

    Also, when downloading the file, is there a difference when doing it if the protocol is HTTP or HTTPS?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Download file to QString

    Quote Originally Posted by Chiggins View Post
    Also, when downloading the file, is there a difference when doing it if the protocol is HTTP or HTTPS?
    The result is the same, but once it is transfered unencrypted and the other time it is encrypted (for the transfering only). See QNetworkAccessManager.

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Download file to QString

    Assuming you use QNetworkAccessManager:
    Connect a slot to the readyRead signal, then use readAll to read the complete response (might take several passes to readyRead!).

    When you have the bytearray, construct a qstring from this bytearray: QString(myByteArray)

    Edit:
    There is a difference between https and http at the protocol level. For you and me, it doesn't matter. Qt handles this behind the scenes.

Similar Threads

  1. I want to download a piece of file?
    By mismael85 in forum General Programming
    Replies: 1
    Last Post: 27th February 2010, 15:35
  2. Download File
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2010, 09:53
  3. Replies: 1
    Last Post: 16th September 2009, 10:59
  4. NEED HELP: How to download file without breaking function
    By codeslicer in forum Qt Programming
    Replies: 10
    Last Post: 22nd April 2008, 04:10
  5. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 01:23

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.