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. QWebView and encoding
Qt 6.11 is out! See what's new in the release blog

QWebView and encoding

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 7.4k Views 1 Watching
  • 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
    p-himik
    wrote on last edited by
    #1

    I have html file which contains form and some inputs with cp1251 encoded data (the forum don't want to post my message with html code).
    When i open this file with Google Chrome and press the button, the site receives data in cp1251 encoding.
    When i create QWebView and call setHtml:
    @QFile file( ":/index.html" );
    QTextStream stream( &file );
    ui->webView->setHtml( stream.readAll() );@
    QWebView displays page correct (there are some russian simbols) but when i press the button the site receives all data in utf-8 encoding.
    Is there some way to make Qt to send all data in cp1251?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Hm... what?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        Is the encoding specified at the meta tags of the HTML that you try to load?

        http://anavi.org/

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p-himik
          wrote on last edited by
          #4

          Yes, it is. Both Chrome and QWebView display page correctly.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leon.anavi
            wrote on last edited by
            #5

            [quote author="p-himik" date="1319718784"]Yes, it is. Both Chrome and QWebView display page correctly.[/quote]

            [quote author="p-himik" date="1319716864"]
            QWebView displays page correct (there are some russian simbols) but when i press the button the site receives all data in utf-8 encoding.
            Is there some way to make Qt to send all data in cp1251?[/quote]

            OK so could you explain in more details what is the button that you press? It would very nice if can share some source code.

            http://anavi.org/

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p-himik
              wrote on last edited by
              #6

              I tried in the main post but forum didn't let me.
              Here is "index.html":http://dl.dropbox.com/u/26596688/index.html

              I used wireshart to check sending data.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                p-himik
                wrote on last edited by
                #7

                I like C++ and Qt at least because they provide many ways to solve single task. I did it with QNetworkAccessManager.
                Though it is a pity that QWebView doesn't have setHtml( QByteArray ).

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  Did you try "QWebView::setContent() ":http://doc.qt.nokia.com/4.7/qwebview.html#setContent?

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

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    p-himik
                    wrote on last edited by
                    #9

                    And again i'm surprised how i could miss it. I guess i need to sleep less. Thanks.
                    But as i have found QWebView::load() suits better since manually forming data lets me get it from my program's interface, not from webpage.

                    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