Unsolved Rendering issue of QTextTable in QTextDocument
-
Hi all!
I got a question about this table in a text document (see below). I have a problem when rendering it in a QTextEdit or print it as PDF file. In both cases the table is not always rendered in the containing (root) frame. Depending on the width of the QTextEdit it is sometimes rendered about 1cm shifted to the right. Resizing the QTextEdit will let the table jump in and out of the frame.
The PDF file shows the same shift.
Any Idea?
HoMQTextDocument* doc = new QTextDocument(); doc->setDocumentMargin(20 *2.83465); QTextFrame* root_frame = doc->rootFrame(); QTextFrameFormat frameFormat = root_frame->frameFormat(); frameFormat.setBorder(1); root_frame->setFrameFormat(frameFormat); QTextCursor c =root_frame->firstCursorPosition(); // get a table QTextTableFormat tableF; tableF.setBorder(1.); tableF.setAlignment(Qt::AlignCenter); tableF.setWidth(QTextLength(QTextLength::PercentageLength, 100)); c.insertTable(5, 6, tableF);
-
I am still interested in this. And by the way: getting a pdf from a QTextDocument looks not very nice to me. The same document printed from word has a much better type setting. Is there a way to improve on that?
regards
HoMa -
Hi,
You should provide a complete minimal compilable example so that people can reproduce your issue and check what's going on.
Here you are not providing the printing part at all.
-
Hi and thanks for your attention.
You are correct - this is not complete. The fastest way to see the problem is to create a Qt widget application, add a button and a QTextEdit control and past the code into the button click event. Last thing to do isui->textEdit->setDocument(doc);
I add two picture of how this looks with only slightly different window widths: