Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QString with diacritical characters
Qt 6.11 is out! See what's new in the release blog

QString with diacritical characters

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 2 Posters 4.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.
  • G Offline
    G Offline
    gandiii
    wrote on last edited by
    #1

    Hello,

    I have made a keyboard with all characters I need, also
    with diacritical characters.
    A Signalmapper mapped with the hex-Code of the character, gives me the
    pressed key.
    But if I press one of the diacritical characters, the program
    doesn't accept it.

    For example:
    ushort from Signalmapper is 0x010C (C with caron).
    I append it to the string tmpString.append(QString::fromUtf16(0x010C,1));

    But this doesn't work, can anybody help me with my problem.
    I really don't know how I get the diacritical symbols working.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I think your use of fromUtf16 is wrong. It expects a c type string in the right encoding, but you're giving it a UTF code point and a length 1. Perhaps you're looking for [[doc:QChar]]? You can create those using the code point, and you can append them to a QString.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gandiii
        wrote on last edited by
        #3

        now I tried it with QChar and it doesn't work.

        example:
        @Signalmapper -> 0x0152 -> QChar test(0x0152)
        QString testString;
        testString.append(test);
        ui.lable->setText(testString);
        @

        Edit: added @ tags around code section; Andre

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          The, something else is off. This code works for me:
          @

          MainWindow::MainWindow(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::Dialog)
          {
          ui->setupUi(this);
          QChar test(0x0152); //this code might as well come from somewhere else...
          QString testString;
          testString.append(test);
          ui->label->setText(testString);
          }

          @

          And please, use @ tags around code sections. They become much easier to read.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gandiii
            wrote on last edited by
            #5

            Is there a global settings for the encoding of a label?
            I wrote the code like above, but it doesn't work.
            could this be a problem of the embedded linux?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Well, I got this as the label: Œ
              That is the correct code point according to the character map application. Using 0x010C results in Č as the contents of my label. Looks good to me.

              Are you sure your font actually contains these code points?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gandiii
                wrote on last edited by
                #7

                i am using the Liberation font and this pdf "Liberation":http://www.ascendercorp.de/pdf/Liberationsans.pdf shows the included charaters.
                i tried it with Æ and this works.

                I have found the problem.
                qt uses the fonts in /usr/lib/fonts/ instead of /usr/share/fonts/
                and if the label is set to Liberation, qt uses a other font
                in its folder.

                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