Qt-interest Archive, December 2007
using QWidget paint routines to print an application view
Message 1 in thread
Greetings.
I'm currently working on an application that generates a lot of similar
reports. Until now, I've been drawing these reports directly to a
QPainter opened on a QPrinter. However, due to the similarity of all
these reports and the fact that they're already displayed in a view in
the application, it seems like there should be a relatively easy way to
render that view to an alternate paint device (the printer).
Unfortunately, I can't seem to find how this would be possible.
Possibilities seem to be:
1. Call QPixmap::grabWidget() on the view and draw the QPixmap to the
printer. However, printing to a file, this yields a ridiculously-sized
(and very poor quality) PostScript file.
2. Call QPainter::setRedirected() and then call update() on the view. I
haven't tried this yet, because it seems like this has serious potential
to go wrong, if the view receives any other paint events before I
restore the original painter.
Am I missing something? Can this easily be done? I've been using Qt
for a while, but this is my first dive into printing. Any advice,
hints, or pointers would be gratefully appreciated.
Thanks,
Darrik
--
[ signature omitted ]