Hi everyone,
I'm new to QT and am running into problems displaying UTF8 data. If anyone with more experience with the library has any thoughts I'd be very grateful to hear them. The code base in question is the "previewer" program in the /examples/webkit/previewer subdirectory. I am trying to get a QString containing Chinese characters to show up in the "HTML Preview" box.
I've spent about three to four hours trying to debug the problem. I can confirm that everything from fonts to system-variables are set up properly. I can also confirm that the QString contains data which was successfully read in from a std::string containing UTF-8 data. I know this because the text is not garbled when printed to the command-line terminal. Nor is it garbled when it is displayed in the "HTML Editing" box. It is only getting garbled when it is displayed in the "HTML Preview" box.
The code that handles HTML processing seems capable of displaying Chinese content though. When I request a random webpage with Chinese characters, I can see that Chinese characters fetched from remote sites work perfectly fine. The following code works fine, for instance:
// webView->setHtml(text); // text is a QString containing Chinese characters
webView->load(tr("http://www.popupchinese.com"));
The problem seems to be with passing a QString through the webView->setHTML function. As a newcomer to QT, I'm somewhat baffled by this, and would love to hear any thoughts or suggestions someone with more experience might have at this point. I'm not sure if this is a bug with the software, or if there is something related to the way the Webkit works that I'm simply missing. The online documentation has not been much help, although I've mostly been googling things and working through the class reference, so suggestions on additional resources would be much appreciated.
Bookmarks