Have trouble draw utf8 string on qgraphicsscene



  • Hello guys,

    I am working on a rss reader client project. I read rss feed and display them with QGraphicsView. But I have problem displaying Chinese characters. My rss should be in UTF8 encoding and I have outputted the QStrings, which contains the content of my rss feed to text files. And the text files can be correctly opened with gedit. So I am assuming that the QStrings are correct.

    But when I try to render the strings with QGraphicsTextItem or using QPainter.drawText(). I can only see messy code outputted. I have tried toUTF8() and other conversions on the QString. didn't have any luck.

    If you can successfully render utf8 strings with QGraphics, can you tell me how to do this?

    Thanks a lot!!!

    !http://dl.dropbox.com/u/13790288/Screenshot.png(an example of the messy code I got)!



  • Hello guys,

    I have tried this, and then it worked like amazing!!

    @
    qgraphicstextitem->setPlainText(QString().fromUtf8(myTroubleQString.toStdString().c_str()));
    @



  • thanks pal, this is really helped me.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.