Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Display webpage using the source code from a QByteArray

    General and Desktop
    5
    6
    2737
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pufo last edited by

      I have a QByteArray which contains the source code of a website.

      I want to display, in my application, the website ( like emulating a browser ), but i want to use the source code from my QByteArray.

      1 Reply Last reply Reply Quote 0
      • D
        dangelog last edited by

        So? Decode the bytes into a string and use QWebView::setHtml.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply Reply Quote 0
        • Z
          ZapB last edited by

          @
          myWebView->setHtml( QString::fromLatin1( byteArray ) );
          @

          assuming that your QByteArray contains latin1 encoded data.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

            Normally, the encoding would be somewhere in the first part of the HTML header. You might need to search for that header, and re-parse the document based on what you find. You can not just assume that it is one encoding or the other. Normally, you'd find the encoding information (also) in the HTTP headers, but I gather that you don't have those?

            1 Reply Last reply Reply Quote 0
            • G
              goetz last edited by

              You should try "QWebView::setContent() ":http://doc.qt.nokia.com/4.7/qwebview.html#setContent, it takes a QByteArray as argument.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply Reply Quote 0
              • A
                andre last edited by

                [quote author="Volker" date="1304374840"]You should try "QWebView::setContent() ":http://doc.qt.nokia.com/4.7/qwebview.html#setContent, it taks a QByteArray as argument.[/quote]

                Even better, of course :-)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post