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. uniCode 0x1D11E to TextLabel

uniCode 0x1D11E to TextLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.7k Views
  • 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.
  • J Offline
    J Offline
    JoWe
    wrote on last edited by
    #1

    I want to output the violin key (uniCode 0x1D11E) in a textlabel
    However, this part of the program gives a Chinese character

    QChar c = 0x1D11E;
    ui->testLabel->setText(c);

    what am I doing wrong?

    K 1 Reply Last reply
    0
    • J JoWe

      I want to output the violin key (uniCode 0x1D11E) in a textlabel
      However, this part of the program gives a Chinese character

      QChar c = 0x1D11E;
      ui->testLabel->setText(c);

      what am I doing wrong?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @JoWe

      According to this page QChar can store only 16 bit unicode.

      For 0x1D11E you need at least 20 bit.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #3

        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);
        
        1 Reply Last reply
        3
        • J Offline
          J Offline
          JoWe
          wrote on last edited by
          #4

          @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 nothing

          Very difficult to understand

          1 Reply Last reply
          0
          • hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #5

            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:
            alt text

            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/

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved