Add special characters as text to QTextEditor or other widgets
-
How to add special characters as text to QTextEditor or other widgets?
For example "l1 /n l2" not to create new line but to display it on single line with special character of newline...
-
How to add special characters as text to QTextEditor or other widgets?
For example "l1 /n l2" not to create new line but to display it on single line with special character of newline...
@Q139 said in Add special characters as text to QTextEditor or other widgets:
"l1 /n l2"
Maybe because it's
\n:)Edit:
Misread your comment.
You need to escape the\nin order to display the\as backslash -
@Q139 said in Add special characters as text to QTextEditor or other widgets:
"l1 /n l2"
Maybe because it's
\n:)Edit:
Misread your comment.
You need to escape the\nin order to display the\as backslash@Pl45m4 If i add another "\" as "l1 \\n l2" then i get "l1 \n l2" to QTextBrowser , but i am unable to write a search function to auto replace every "\" with "\\"
-
@Pl45m4 If i add another "\" as "l1 \\n l2" then i get "l1 \n l2" to QTextBrowser , but i am unable to write a search function to auto replace every "\" with "\\"
@Q139 said in Add special characters as text to QTextEditor or other widgets:
but i am unable to write a search function to auto replace every "" with ""
Why not? What did you try?
-
@Pl45m4 If i add another "\" as "l1 \\n l2" then i get "l1 \n l2" to QTextBrowser , but i am unable to write a search function to auto replace every "\" with "\\"
-
@Q139 said in Add special characters as text to QTextEditor or other widgets:
but i am unable to write a search function to auto replace every "" with ""
Why not? What did you try?
text.indexOf('\'); //wont compile text.indexOf('\\'); //wont find the text as special chars are threated as single char.. -
@Pl45m4 how to replace it without seeking for each special char seperately?
After compiled to string it is threated as single special char...
Basically id like to show all info as raw text in text browser. Including \n \r etc but incoming data format is QString... -
text.indexOf('\'); //wont compile text.indexOf('\\'); //wont find the text as special chars are threated as single char..@Q139 said in Add special characters as text to QTextEditor or other widgets:
text.indexOf('\'); //wont compile
Of course not.
Regarding text.indexOf('\'); : you want to replace new-lines, right? So, it should be:
text.indexOf('\n');To replace a simple
someString.replace("\n", "\\n"); -
@Q139 said in Add special characters as text to QTextEditor or other widgets:
text.indexOf('\'); //wont compile
Of course not.
Regarding text.indexOf('\'); : you want to replace new-lines, right? So, it should be:
text.indexOf('\n');To replace a simple
someString.replace("\n", "\\n");@jsulm Not only new lines but all special chars..
I guess 1 way is to loop trough text and use isNonCharacter() then add the extra "\"
-
@jsulm Not only new lines but all special chars..
I guess 1 way is to loop trough text and use isNonCharacter() then add the extra "\"
-
@Pl45m4 Nice try
-
@Pl45m4 Nice try
@Q139 One idea would be to take a look at qDebug() implementation as it does this at least for some special characters (like new lines).
-
@Pl45m4 Nice try
@Q139 im afraid compiler removes 2 chars and replaces with 1 as there are not enough keys on keyboard for special chars.
-
@Q139 im afraid compiler removes 2 chars and replaces with 1 as there are not enough keys on keyboard for special chars.
-
I have incoming data in QString format...