I have a QPlainTextEdit
that contains some text. Word wrap is enabled.
When I retrieve the text with toPlainText()
the resulting string does not contain the newline characters created from word wrap. This is because those newline characters weren't directly entered by the user.
I would like to retain those newline characters that word wrap created. How does one do this?
For example:
Add QPlainTextEdit
widget to the window and fill it with enough text for word wrap to create new lines.
Output that text to file:
QString myText = ui->plainTextEdit->toPlainText();
QFile outputFile("test.txt");
outputFile.open(QIODevice::WriteOnly);
outputFile.write(myText.toUtf8());
outputFile.close();
The resulting output is just 1 line.
How can I retain the newline characters word wrap simulates?