0

I want to add an Unicode Symbol as a list widget item in QT. (Particularly this item : http://www.fileformat.info/info/unicode/char/25B6/index.htm )

I'm using following method for this :

this->addItem( new QListWidgetItem(  QString::fromUtf8("\u25B6")) ) ; 

But when I open the widget I see only a blank rectangle in place of this unicode symbol. I even tried other unicode symbols too, but they too are showing only blank rectangle.

What's wrong in this method?

EDIT: After following the answer, I changed the font of QListWidgetItem to Serif and it worked.

Maverick33
  • 337
  • 3
  • 15

1 Answers1

1

There are several possibilities, but the most probable one is that the font you are using doesn't implement the glyph at all. Can you see the triangle in eg. an editor when using the same font as your Qt font?

Edit: The fonts (which are stored in the system's font files) are the commands to draw the images of each character on the screen). Many (if not all) fonts are incomplete, which means they are not able to represent all 2,000,000,000+ codes which are possible in the unicode (the numbers which represent the characters). The files would just be to large to be practical.

The triangles you want printed are fairly basic, and should be available in many font sets. Liberation Sans and Liberation Serif are two I just checked.

I suspect Qt uses the font set of the system, which can probably be changed in the System Settings somewhere. If you tell us which distribution you are using (i.e. Ubuntu, Debian, ...), maybe we can help.

jcoppens
  • 5,306
  • 6
  • 27
  • 47
  • I don't exactly follow what does it mean by font. I printed put that string on terminal and it's printing '?' in place of the unicode character. How can I see if the font is responsible for this? – Maverick33 Jul 17 '14 at 16:30
  • @MrEricSir No, I haven't tried it yet, actually I don't know how can I change that. Basically I don't have much idea how changing font will change something :( Anyway, even if it works( i.e. changing terminal font), would it help debugging the actual problem? Do I have to change some font in QT/C++ code to display the symbol on the widget? – Maverick33 Jul 17 '14 at 17:39
  • After googling a bit about fonts, I get the point. Unicode symbols are supported in some particular font. My widget was by default using Helvetica and I changed it to Serif and it worked! Thanks. – Maverick33 Jul 17 '14 at 18:41