I need to format and manage text in a QTextEdit. The text "items" are usually one line long, such as
However, sometimes they are several lines long, such as
Nr1234 Munich some lengthy comment \n some more \n and more
this messes up my text managing, since i work over QTextBlocks. And every line break generates a new TextBlock.
I tried to wrap all my items in QTextFrames, but that generates unwanted linebreaks itself (ie the QTextFrame generates a linebreak automatically).
for(...)
{
QTextCursor tc
= txtedit
->document
()->rootFrame
()->lastCursorPosition
();
tc.insertText("testline");
}
for(...)
{
QTextCursor tc = txtedit->document()->rootFrame()->lastCursorPosition();
tc.insertFrame(QTextFrameFormat());
tc.insertText("testline");
}
To copy to clipboard, switch view to plain text mode
will output:
testline
testline
testline
testline
testline
testline
testline
testline
To copy to clipboard, switch view to plain text mode
How can i have a textblock that spans several lines? Or: how can i not have automatic linebreaks after the qtextframe?
Observation: if my textblock is very long, but doesnt contain any linebreaks, it is wrapped automatically and all works well. The problme occurs when i try to process linebreaks that are in the string itself.
Bookmarks