Important: Please read the Qt Code of Conduct -

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

  • 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 ) 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 !

  • Lifetime Qt Champion

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

    QPixmap pixmap(widget->size());

  • 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 !

Log in to reply