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. How to know end of page?

How to know end of page?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k 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.
  • F Offline
    F Offline
    Fahmy
    wrote on last edited by
    #1

    I'm using QPainter and QPrinter to print PDF file. Let say, I'm using drawText() to paint a very long paragraph, how to know it has reach the bottom of the page and create a new page?

    Stay hungry, stay foolish.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      QPrinter provides a pageRect() and paperRect() which you can compare against QFontMetrics of the QPainter opened on the printer instance.
      I generally recommend reading the "printing with qt" tutorial of the Qt Documentation:
      http://doc.qt.digia.com/qt/printing.html

      Note that for printing something that could be called a text document you'll probably have an easier life by using QTextDocument and maybe extending it (own layouts, inline elements, etc.). It already brings pagination of content and printing capabilities.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fahmy
        wrote on last edited by
        #3

        Thanks for the answer. I've already use QTextDocument, but have some problem when printing image file. That's why I try to use QPainter instead.

        Stay hungry, stay foolish.

        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