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. How to write a radical symbol in a string list?
Forum Updated to NodeBB v4.3 + New Features

How to write a radical symbol in a string list?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • T Offline
    T Offline
    tomy
    wrote on 24 Jan 2017, 09:19 last edited by
    #1

    Hello all,

    For a program I need to write a radical symbol is a QStringlist. I found that using ALT+251 (like here √) I can insert it but in main().cpp it doesn't work! How to put that character there please?

    K 1 Reply Last reply 24 Jan 2017, 09:31
    0
    • T tomy
      24 Jan 2017, 09:19

      Hello all,

      For a program I need to write a radical symbol is a QStringlist. I found that using ALT+251 (like here √) I can insert it but in main().cpp it doesn't work! How to put that character there please?

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 24 Jan 2017, 09:31 last edited by
      #2

      Well, strings aren't exactly for this, but you can escape the unicode sequence. Something like this:

      QStringLiteral("\u221A");
      

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      3
      • E Offline
        E Offline
        Eeli K
        wrote on 24 Jan 2017, 11:10 last edited by
        #3

        Basically it can work, but the compiler doesn't necessarily automatically interpret the source file encoding. You should take care that source file is e.g. UTF-8 encoded and that the compiler handles the file as UTF-8. Most probably, if you already can copy the symbol and see it correctly in your editor, it's in UTF-8 format. In Qt Creator the default encoding is UTF-8, at least for me. In g++ the default should also be UTF-8. If it still doesn't work, you have to give more details. Or just use the unicode codepoint as kshegunov told, it's the easy and safe solution if you have only few such symbols.

        1 Reply Last reply
        1
        • E Offline
          E Offline
          Eeli K
          wrote on 24 Jan 2017, 11:17 last edited by
          #4

          Just tested: copypasted to Qt Creator, compiled with mingw and √ was correctly visible in the app UI.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tomy
            wrote on 24 Jan 2017, 11:19 last edited by
            #5

            first I need to recover my file. Then I can test them. Please have a look here
            https://forum.qt.io/topic/75431/recover-source-after-power-cut

            1 Reply Last reply
            0

            1/5

            24 Jan 2017, 09:19

            • Login

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