Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display webpage using the source code from a QByteArray
QtWS25 Last Chance

Display webpage using the source code from a QByteArray

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 3.1k Views
  • 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 Offline
    P Offline
    Pufo
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

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

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

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #3

        @
        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
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              [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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved