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. Print or take a screen of a QWidget in order to put it in a QTextDocument
QtWS25 Last Chance

Print or take a screen of a QWidget in order to put it in a QTextDocument

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

    Hello all,

    I need to create a PDF report, so i've managed so far to insert text, header, footer, tables, graphics and images in the document, using QTextDocument/QPrinter/QPainter.

    I've been asked to insert a thermometer (with a variable filling rate of course) in the report. First I tried to draw it myself, but i'm not that good of a designer ;)

    So i have the idea of using an existing QWidget that can look like what i want (check this for instance http://qt-apps.org/content/show.php/AnalogWidgets?content=87780 ) and like i want to know if it's possible to "print" or "screen" the QWidget so i can put that image in the report.

    Thanks in advance !

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

      Hi
      Have you looked at render() ?
      It can make the widget draw it to other surfaces which hopefully would include PDF

      QPixmap pixmap(widget->size());
      widget->render(&pixmap);

      1 Reply Last reply
      1
      • L Offline
        L Offline
        LauraB
        wrote on last edited by
        #3

        Hey,

        I'm gonna definitely look into it today, I'm going back here to mark problem as solved if this turned to work !

        Thanks a lot anyway !

        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