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


  • Qt Champions 2016

    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);



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.