Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebView and encoding



  • 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?



  • Hm... what?



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



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



  • [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.



  • 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.



  • 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 ).



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



  • 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.


Log in to reply