Reputation: 21
I am using QTextdocument and in my text there are "\n" for new line characters but QTextDocument is not handling it and it shows it as plain 1 line . Is there any way we can make it handle "\n" as new line character, along with that I need eliding also. So whenever any text is there after line break it should show "..."
E.g.
This
is
the
Sample
Currently QTextdocument removed line breaks and shows it as "This is the sample" 2nd issue is for eliding Now suppose only 1 line is visible it should show it as "This..." How do I achieve this?
Upvotes: 2
Views: 1264
Reputation: 32655
QTextDocument
holds formatted text, so you can use <br>
html tag for a new line and set it's content using QTextDocument::setHtml
.
Also you cab use QTextDocument::setTextWidth
to set a specific width for text in the document. If the content is wider, it is broken into multiple lines and grows vertically.
About eliding you can see this bug report which is unresolved.
Upvotes: 3