View Full Version : Horizontal line in QTextDocument

10th February 2011, 15:30
Hi, I'm creating a QTextDocument and print it as PDF to a QPrinter with QTextDocument::print (). I can create text and tables, but I would like to insert a simple horizontal line to separate some paragraphs.

I tried to create an empty frame like this:

QTextFrameFormat oLineFormat;
oLineFormat.setHeight (1);
oLineFormat.setWidth (100);
oLineFormat.setBorderStyle (QTextFrameFormat::BorderStyle_Solid);
oDocumentCursor.insertFrame (oLineFormat);
oDocumentCursor.insertText (" ");

but it did not shown up in my printed PDF.

I read the text object example, but do I really have to create my own TextObject for this? Or is there a simpler way to draw a line?


10th February 2011, 23:16
The easiest way is to call:


If you wish to know how to insert a line "manually", analyze the block inserted by the above statement and modify it to suit your needs.

11th February 2011, 09:37
Thanks, I did not think about HTML :)