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. Nicely paginate a QTextDocument
Forum Updated to NodeBB v4.3 + New Features

Nicely paginate a QTextDocument

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 624 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.
  • mcmayerM Offline
    mcmayerM Offline
    mcmayer
    wrote on last edited by mcmayer
    #1

    QTextDocument allows to nicely render text by using setHtml and then using drawContents in the paintEvent.
    What completely eludes me, after having read almost all the concerning docs , is how to avoid the ugly cutoff when the rendered text overshoots.
    QTextEdit, or any of its superclasses, is not a solution because it brings with it the scrollbar(s) which I really don't want. Instead the user should be able to paginate through the document, for example by using the arrow keys (on the desktop) or by tapping (on a device with a touchscreen).

    So far I have explored two approaches:

    1. Go into the nitty-gritty and manually calculate the height of each QTextBlock, see here for a failed attempt (the height calculation doesn't work on blocks that span more than one line). No correct solution has transpired, so far.
    2. Do use QTextEditand set the scrollbars to ScrollBarAlwaysOff. Then somehow make it not overspill. Then make it paginate nicely.

    It seems like the machinery to do this is there, after all for printing it's necessary to paginate. So there must be a mechanism.

    Any hints on how to approach this would be greatly appreciated!

    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