Mr.Green
17th March 2015, 14:48
Hi all.
my Question is very similar to this one (http://www.qtcentre.org/threads/43345-printing-widget%28s%29-to-postscript-or-PDF-using-vector-graphics-and-not-pixmap-backing) which hasn't been answered.
How do I print Widgets "in the right way"?
I've got a bunch of Widgets in a Layout that I want to be printed out.
My idea was:
auto printer = new QPrinter(QPrinter::ScreenResolution);
...
QPainter painter;
painter.begin(printer);
//Scale to Page Size
double xscale = printer->pageRect().width() / double(m_current_page->page->width());
double yscale = printer->pageRect().height() / double(m_current_page->page->height());
painter.scale(xscale, yscale);
content->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); //I've also simply using content->render(&painter);
This seemed to be very easy, but the problem now is:
I may choose between Highresolution and slow printing and big Filesize (when printing to a PDF).
Or: bad Resolution.
My question is: Why does Qt print by rasterizing the whole Widgets (including their Labels etc). into Pixmaps?
And what can I do against that?
Or am I completely wrong when trying to print them this way?
Thanks.
Mr.Green
my Question is very similar to this one (http://www.qtcentre.org/threads/43345-printing-widget%28s%29-to-postscript-or-PDF-using-vector-graphics-and-not-pixmap-backing) which hasn't been answered.
How do I print Widgets "in the right way"?
I've got a bunch of Widgets in a Layout that I want to be printed out.
My idea was:
auto printer = new QPrinter(QPrinter::ScreenResolution);
...
QPainter painter;
painter.begin(printer);
//Scale to Page Size
double xscale = printer->pageRect().width() / double(m_current_page->page->width());
double yscale = printer->pageRect().height() / double(m_current_page->page->height());
painter.scale(xscale, yscale);
content->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); //I've also simply using content->render(&painter);
This seemed to be very easy, but the problem now is:
I may choose between Highresolution and slow printing and big Filesize (when printing to a PDF).
Or: bad Resolution.
My question is: Why does Qt print by rasterizing the whole Widgets (including their Labels etc). into Pixmaps?
And what can I do against that?
Or am I completely wrong when trying to print them this way?
Thanks.
Mr.Green