tuli
27th July 2014, 08:43
I need to format and manage text in a QTextEdit. The text "items" are usually one line long, such as
Nr1233 Munich abcd
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.insertFrame(QTextFrameFormat());
tc.insertText("testline");
}
will output:
testline
testline
testline
testline
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.
Nr1233 Munich abcd
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.insertFrame(QTextFrameFormat());
tc.insertText("testline");
}
will output:
testline
testline
testline
testline
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.