QString with consecutive "_" becomes underline ?
-
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 -
-
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
-
@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 -
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.
-
@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 -
@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
-
@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).
-
@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. -
@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 -
@koahnig said in QString with consecutive "_" becomes underline ?:
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.
-