Results 1 to 20 of 28

Thread: How to download a file using HTTP with URL in QT?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default How to download a file using HTTP with URL in QT?

    Qt Code:
    1. QUrl url = QUrl::fromUserInput(strUrl);
    2. QFileInfo fileInfo(url.path());
    3. QString fileName=fileInfo.fileName();
    4. if (QFile::exists(fileName)) {
    5. QMessageBox::information(this, tr("HTTP"),
    6. tr("There already exists a file called %1 in "
    7. "the current directory.")
    8. .arg(fileName));
    9. }
    10.  
    11. file = new QFile(fileName);
    12. if (!file->open(QIODevice::WriteOnly)) {
    13. QMessageBox::information(this, tr("HTTP"),
    14. tr("Unable to save the file %1: %2.")
    15. .arg(fileName).arg(file->errorString()));
    16. delete file;
    17. file = 0;
    18. }
    19.  
    20. file.setFileName(fileName);
    21. file.open(QIODevice::WriteOnly);
    22. QHttp *http;
    23. http=new QHttp(this);
    24. setHost(url.host(),QHttp::ConnectionModeHttp);
    To copy to clipboard, switch view to plain text mode 


    Am getting while using the HTTP . It says undefined reference to the http object.
    I just want to download a file from the host.
    Last edited by wysota; 8th March 2011 at 09:26. Reason: missing [code] tags

Similar Threads

  1. HTTP pause download in QTCreator
    By nhs_0702 in forum Qt Programming
    Replies: 12
    Last Post: 29th November 2010, 15:24
  2. Download file to QString
    By Chiggins in forum Qt Programming
    Replies: 2
    Last Post: 25th June 2010, 20:16
  3. I want to download a piece of file?
    By mismael85 in forum General Programming
    Replies: 1
    Last Post: 27th February 2010, 16:35
  4. Download File
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2010, 10:53
  5. Download via HTTP in several threads?
    By bjilly in forum Qt Programming
    Replies: 6
    Last Post: 30th November 2009, 15: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
  •  
Qt is a trademark of The Qt Company.