uniCode 0x1D11E to TextLabel
-
I want to output the violin key (uniCode 0x1D11E) in a textlabel
However, this part of the program gives a Chinese characterQChar c = 0x1D11E;
ui->testLabel->setText(c);what am I doing wrong?
-
Just to add to @koahnig. QChar is indeed not well suited for Unicode chars > 0xFFFF, instead try QString::fromUcs4 for example this gives you the 11 o'clock symbol:
uint a[] = {0x1F55A}; QString s = QString::fromUcs4(a,1); ui->testLabel->setText(s);
For the violin key character usually you have to prefix it with something to make it visible, for example use 3 blanks, like this:
uint a[] = {0x1D11E}; QString s = " " + QString::fromUcs4(a,1); ui->testLabel->setText(s);
-
@hskoglund said in uniCode 0x1D11E to TextLabel:
Thank you, it helped.
Now I get:
At 0x1F55A 🕚 is correct
At 0x1F6F3 🛳 is correct
At 0x1F6F2 nothing
At 0x1D11E nothingVery difficult to understand
-
Hi, I made an example, using 2 test labels:
uint a[] = {'a',0x1F55A,'b',0x1F6F3,'c',0x1F6F2,'d',0x1D11E,'e',0}; QString s = QString::fromUcs4(a); ui->testLabel->setText(s); ui->testLabel2->setText(s);
Here's the result on my Windows PC:
Why is it different? The second label (with all the squares) uses the "Times New Roman" font. Most fonts are like this, very few Unicode characters exist in them (instead just squares).
To be able to see all the symbols, for the first label I use the "Symbola" font, which is one recommended by the Unicode consortium. Download it here.
Also, note the 0x1D11E is symbol drawn 2 places to the left, that's why I added 3 spaces to my first example above.P.S. Also see xkcd's view on Unicode: https://xkcd.com/1726/