QwtPlot->print on QPrinter
Brought to you by:
rathmann
|
From: Christian L. <chr...@la...> - 2008-07-01 14:52:10
|
Hi Everybody,
I have a problem when trying to print a QwtPlot onto a QPrinter to get a
nice PDF. It works if I use an QImage as paint device and then print
that, though.
My code looks like this:
QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
printer.setPageSize(QPrinter::A4);
QPainter painter(&printer);
QRect page = printer.pageRect();
int w = page.width()-page.x();
QRect rect(page.x(), page.y(), w, w/60*80);
for (int i=0; i<plots.size(); ++i) {
plots[i]->print(&painter, rect);
if (i+1<plots.size()) printer.newPage();
}
Here I add four pages with plots. Examples with Qt 4.3.2 and Qt 4.4.0 are shown
here:
http://www.spect-ct.com/plots/qt-4.3.2.pdf
http://www.spect-ct.com/plots/qt-4.4.0.pdf
I already tried Qwt 5.0.2, 5.1.0, 5.1.1 and trunk from today with the same
results. Is it just something special I do or is there something broken in
Qt/Qwt? Can try to produce a minimal example, but that could get
complicated and I just hope somebody can explain this behavior even from
this little information.
The workaround with a bitmap QImage does not look nearly as nice as the
direct PDF printing. Is there any other workaround I could try?
Thanks for your time.
Best regards,
Christian
--
http://www.spect-ct.com/
|