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. QTextDocument using TableHeaderRowCount with html contents
Forum Updated to NodeBB v4.3 + New Features

QTextDocument using TableHeaderRowCount with html contents

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 248 Views 1 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.
  • V Offline
    V Offline
    vakokako
    wrote on last edited by
    #1

    Hi, we are using QTextDocument::print(QPdfWriter*) to print html contents to pdf. In our documents we use tables. See the attached pdf screenshot for example.

    The problem is when the table is at the end of the page and it's size is too big, instead of moving this table to the next page, QTextDocument splits the table in two parts. I've read that this can be prevented by setting the TableHeaderRowCount to number of rows, and it actually worked when using QTextCursor::insertTable, but we create our document from the html.

    What is the best way to prevent table splitting in QTextDocument with html contents?

    c9e7ae2c-1901-4c07-90af-982950af1bb9-image.png

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

      Hi and welcome to devnet,

      If memory serves well, you will have to do the math yourself.

      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
      0
      • V Offline
        V Offline
        vakokako
        wrote on last edited by
        #3

        There is a way to iterate over all the formats QTextDocument::allFormats, then check for the QTextFormat::TableHeaderRowCount property. The problem is, I cannot find a way to change these formats, since they are returned as a copy.

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

          The usual way is to modify the copy and then reapply it.

          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
          0

          • Login

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