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. Have trouble draw utf8 string on qgraphicsscene
Qt 6.11 is out! See what's new in the release blog

Have trouble draw utf8 string on qgraphicsscene

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k 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.
  • B Offline
    B Offline
    billconan
    wrote on last edited by
    #1

    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)!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      billconan
      wrote on last edited by
      #2

      Hello guys,

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

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

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Krong
        wrote on last edited by
        #3

        thanks pal, this is really helped me.

        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