QTextEdit, how to insert multiple lines?
-
wrote on 24 Feb 2021, 11:58 last edited by
I have a QTextEdit in a form, how do I display text on separate lines? From am SQL database I have an entry that is an house address, each line of the address is delimited with a carriage return (13).
To add this to the control I use the text function, but the lines are just displayed as a single with no carriage return.
Is there a standard way to achieve this? I've tried googling QTextEdit and Multiline entry but didn't find anything specific to my issue.
-
I have a QTextEdit in a form, how do I display text on separate lines? From am SQL database I have an entry that is an house address, each line of the address is delimited with a carriage return (13).
To add this to the control I use the text function, but the lines are just displayed as a single with no carriage return.
Is there a standard way to achieve this? I've tried googling QTextEdit and Multiline entry but didn't find anything specific to my issue.
@SPlatten Are you on Windows? If so try to replace "\n" with "\r\n".
-
@SPlatten Is there a difference if you use setPlainText?
-
wrote on 24 Feb 2021, 12:06 last edited by
@jsulm , I've just inserted:
strText.replace("\n", "\r\n");
Before setting the text, that didn't make any difference, replaced setText call with setPlainText. No difference either that was also with the replace statement still in.
-
@jsulm , I've just inserted:
strText.replace("\n", "\r\n");
Before setting the text, that didn't make any difference, replaced setText call with setPlainText. No difference either that was also with the replace statement still in.
@SPlatten I can't test on Mac, but on Windows setting text with \n using setText() works correctly.
-
@SPlatten I can't test on Mac, but on Windows setting text with \n using setText() works correctly.
-
wrote on 24 Feb 2021, 12:41 last edited by
Keep calm and take some time to look at debugger. Again, spending more time writing here than inspecting the debugger.
-
wrote on 24 Feb 2021, 12:44 last edited by
Use Append Function for It
QTextEdit::append("Your String");
3/9