Results 1 to 9 of 9

Thread: How to read the contents of the QHTTP file in QString?

Hybrid 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 read the contents of the QHTTP file in QString?

    How to read the contents of the QHTTP file in QString? I want to read the contents of the file in http and am using QHTTP for it. How to read it in QString or any other variables.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to read the contents of the QHTTP file in QString?

    Read the data into a QByteArray then, assuming the data is actually text, use either:
    Qt Code:
    1. // QByteArray ba
    2. QString str = QString::fromUtf8(ba.constData(), ba.size());
    3. QString str = QString::fromAscii(ba.constData(), ba.size());
    4. // or one of the other variants
    To copy to clipboard, switch view to plain text mode 

  3. #3
    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 Re: How to read the contents of the QHTTP file in QString?

    How to read the contents from QHTTP in a bytearray?

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    18
    Thanked 68 Times in 66 Posts

    Default Re: How to read the contents of the QHTTP file in QString?

    by using a method that returns a QByteArray. You'll find it in the documentation.

    just to mention it the 134281246874th time:

    This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Similar Threads

  1. Read QString from file
    By justin123 in forum Qt Programming
    Replies: 11
    Last Post: 16th March 2011, 23:22
  2. Display contents of .txt file
    By karmo in forum Newbie
    Replies: 17
    Last Post: 23rd January 2010, 21:39
  3. Read binary file and convert to QString
    By jaca in forum Qt Programming
    Replies: 12
    Last Post: 14th June 2008, 00:05
  4. Replies: 13
    Last Post: 21st June 2006, 22:22

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
  •  
Qt is a trademark of The Qt Company.