Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendering issue of QTextTable in QTextDocument
Forum Updated to NodeBB v4.3 + New Features

Rendering issue of QTextTable in QTextDocument

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 351 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • HoMaH Offline
    HoMaH Offline
    HoMa
    wrote on last edited by
    #1

    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?
    HoM

        QTextDocument* 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);
    
    
    1 Reply Last reply
    0
    • HoMaH Offline
      HoMaH Offline
      HoMa
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • HoMaH Offline
          HoMaH Offline
          HoMa
          wrote on last edited by
          #4

          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 is

          ui->textEdit->setDocument(doc);
          

          I add two picture of how this looks with only slightly different window widths:

          qtextdocument-table-ok.PNG qtextdocument-table-Nok.PNG

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved