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. QString with consecutive "_" becomes underline ?
Forum Updated to NodeBB v4.3 + New Features

QString with consecutive "_" becomes underline ?

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 5.1k Views 2 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.
  • R ranshalit

    Hello,

    I am creating QString with consecutive "_" using monospace text, but I see that instead of creating them separately (which is what I need) like this: "____" , it creates a bottom line (connects them all together).

    How can I create them separately instead while still using monospace?

    Thank you.
    Ran

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

    @ranshalit

    Not sure what you want to do.
    For quotes (single or double) you have to to use escape sequences, because they have special roles in C/C++. An underline shall be no problem AFAIK.

    A string with a single quote would be

    QString singleQuote ("\'"); // basically double quote, back slash, single quote, double quote
    QString doubleQuote ("\""); // basically double quote, back slash, double quote, double quote
    QString underline ("_"); // basically double quote, underline, double quote
    

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

    R 1 Reply Last reply
    0
    • K koahnig

      @ranshalit

      Not sure what you want to do.
      For quotes (single or double) you have to to use escape sequences, because they have special roles in C/C++. An underline shall be no problem AFAIK.

      A string with a single quote would be

      QString singleQuote ("\'"); // basically double quote, back slash, single quote, double quote
      QString doubleQuote ("\""); // basically double quote, back slash, double quote, double quote
      QString underline ("_"); // basically double quote, underline, double quote
      
      R Offline
      R Offline
      ranshalit
      wrote on last edited by ranshalit
      #3

      @koahnig said in QString with consecutive '_':
      Hi,

      I see what you mean, I fixed the question above.

      I am trying to create Qstring with consective "_" such as the following: "__" .
      The problem is that the QString becomes underline, which is not what I wanted.
      Is there a way to create it like the following "__" (separated) ?

      Thank you,
      Ran

      K 1 Reply Last reply
      0
      • R ranshalit

        @koahnig said in QString with consecutive '_':
        Hi,

        I see what you mean, I fixed the question above.

        I am trying to create Qstring with consective "_" such as the following: "__" .
        The problem is that the QString becomes underline, which is not what I wanted.
        Is there a way to create it like the following "__" (separated) ?

        Thank you,
        Ran

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

        @ranshalit

        That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

        You need to try different fonts.

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

        R E 2 Replies Last reply
        4
        • K koahnig

          @ranshalit

          That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

          You need to try different fonts.

          R Offline
          R Offline
          ranshalit
          wrote on last edited by ranshalit
          #5

          @koahnig
          Hi,
          The problem is that I need to use monospace , because I need the characters (digits actually) to appear in the exact space between each digit. When I use other font it will fail to have this feature.
          My only problem is that with monospace font, consecutive "/" becomes underline...
          Is there maybe another character similar to "
          " without becoming underline ?

          Thank you.
          Ran

          VRoninV 1 Reply Last reply
          1
          • R ranshalit

            @koahnig
            Hi,
            The problem is that I need to use monospace , because I need the characters (digits actually) to appear in the exact space between each digit. When I use other font it will fail to have this feature.
            My only problem is that with monospace font, consecutive "/" becomes underline...
            Is there maybe another character similar to "
            " without becoming underline ?

            Thank you.
            Ran

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #6

            @ranshalit said in QString with consecutive "_" becomes underline ?:

            Is there maybe another character similar

            There are many, for example: https://unicode-table.com/en/23BD/ or https://unicode-table.com/en/035F/ depends if your font support them

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            R 1 Reply Last reply
            2
            • K koahnig

              @ranshalit

              That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

              You need to try different fonts.

              E Offline
              E Offline
              Eeli K
              wrote on last edited by
              #7

              @koahnig said in QString with consecutive "_" becomes underline ?:

              That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

              "Feature, not a bug". See https://en.wikipedia.org/wiki/Underscore. It is meant for underlining for historical reasons and visually separate lines are unexpected. @ranshalit See VRonin's links or find an Open Source monospace font and modify it manually using FontForge (not so difficult in this case, really, if you only shorten the underscore).

              K 1 Reply Last reply
              3
              • E Eeli K

                @koahnig said in QString with consecutive "_" becomes underline ?:

                That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

                "Feature, not a bug". See https://en.wikipedia.org/wiki/Underscore. It is meant for underlining for historical reasons and visually separate lines are unexpected. @ranshalit See VRonin's links or find an Open Source monospace font and modify it manually using FontForge (not so difficult in this case, really, if you only shorten the underscore).

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

                @Eeli-K said in QString with consecutive "_" becomes underline ?:

                @koahnig said in QString with consecutive "_" becomes underline ?:

                That should be a font issue to my understanding. You are actually storing a number of consecutive underlines, but in the font they are too long and they are displayed as one long line. This is what people typically expect.

                "Feature, not a bug". See https://en.wikipedia.org/wiki/Underscore. It is meant for underlining for historical reasons and visually separate lines are unexpected. @ranshalit See VRonin's links or find an Open Source monospace font and modify it manually using FontForge (not so difficult in this case, really, if you only shorten the underscore).

                Yes, of course!
                The "too long" is not to interpret as "bug". It was meant for clarity for reader. All those features go back to good DOS and before that.

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

                1 Reply Last reply
                1
                • VRoninV VRonin

                  @ranshalit said in QString with consecutive "_" becomes underline ?:

                  Is there maybe another character similar

                  There are many, for example: https://unicode-table.com/en/23BD/ or https://unicode-table.com/en/035F/ depends if your font support them

                  R Offline
                  R Offline
                  ranshalit
                  wrote on last edited by ranshalit
                  #9

                  @VRonin
                  Thanks !
                  That seemed promising , but seems that monospace does not support it :( (it appears but does not behave like monospace ).
                  The other solution of modifying monospace font seems a bit complex for me now.
                  Maybe I can add some space between characters in Qlabel ?

                  Thanks,
                  Ran

                  K 1 Reply Last reply
                  0
                  • R ranshalit

                    @VRonin
                    Thanks !
                    That seemed promising , but seems that monospace does not support it :( (it appears but does not behave like monospace ).
                    The other solution of modifying monospace font seems a bit complex for me now.
                    Maybe I can add some space between characters in Qlabel ?

                    Thanks,
                    Ran

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

                    @ranshalit

                    What are you trying anyhow?

                    QLabel lbl ("_ _ _ ");
                    

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

                    M R 2 Replies Last reply
                    0
                    • K koahnig

                      @ranshalit

                      What are you trying anyhow?

                      QLabel lbl ("_ _ _ ");
                      
                      M Offline
                      M Offline
                      mchinand
                      wrote on last edited by
                      #11

                      @koahnig said in QString with consecutive "_" becomes underline ?:

                      @ranshalit

                      What are you trying anyhow?

                      QLabel lbl ("_ _ _ ");
                      

                      I'm not exactly sure what the original poster is trying to achieve, but another possible character to use is the 'open box' (␣) to indicate a space.

                      https://unicode-table.com/en/2423/

                      R 2 Replies Last reply
                      1
                      • K koahnig

                        @ranshalit

                        What are you trying anyhow?

                        QLabel lbl ("_ _ _ ");
                        
                        R Offline
                        R Offline
                        ranshalit
                        wrote on last edited by
                        #12

                        @koahnig
                        yes, that is what I try.

                        1 Reply Last reply
                        0
                        • M mchinand

                          @koahnig said in QString with consecutive "_" becomes underline ?:

                          @ranshalit

                          What are you trying anyhow?

                          QLabel lbl ("_ _ _ ");
                          

                          I'm not exactly sure what the original poster is trying to achieve, but another possible character to use is the 'open box' (␣) to indicate a space.

                          https://unicode-table.com/en/2423/

                          R Offline
                          R Offline
                          ranshalit
                          wrote on last edited by ranshalit
                          #13

                          @mchinand
                          Thank you., I will try the open box character. I hope it is supported in monospace font.

                          1 Reply Last reply
                          1
                          • M mchinand

                            @koahnig said in QString with consecutive "_" becomes underline ?:

                            @ranshalit

                            What are you trying anyhow?

                            QLabel lbl ("_ _ _ ");
                            

                            I'm not exactly sure what the original poster is trying to achieve, but another possible character to use is the 'open box' (␣) to indicate a space.

                            https://unicode-table.com/en/2423/

                            R Offline
                            R Offline
                            ranshalit
                            wrote on last edited by ranshalit
                            #14

                            @mchinand
                            the openbox was not supported in font, but I eventually managed to use "_"
                            with any space as I need as following:
                            newFont.setStyleHint(QFont::Monospace);
                            newFont.setLetterSpacing(QFont::AbsoluteSpacing,3);

                            Thanks,
                            Ran

                            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