Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Help with breaklines on PlainTextEdit
-
Why the PlainText was not accept the break line of the text file? Someone know some solution for this?
text.txt content = hello\nworld
with open('text.txt') as x: y = x.read() self.shell_host.insertPlainText(y) string = 'hello\nworld' self.shell_host.insertPlainText(string)
Output:
-
@Black-Cat In the .txt you have 12 characters since "\n" is 2 characters but "\n" is a character (carrier return). A possible solution is to replace those 2 characters with the one you want:
with open('text.txt') as x: y = x.read() y = y.replace("\\n", "\n") # or # y = y.replace(r"\n", "\n") self.shell_host.insertPlainText(y)