PDA

View Full Version : Printing Widgets: Why are they rendered into Pixmap / Bitmap?



Mr.Green
17th March 2015, 15: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

wysota
17th March 2015, 15:56
Why does Qt print by rasterizing the whole Widgets (including their Labels etc). into Pixmaps?
Because widgets are drawn using raster graphics.


And what can I do against that?
Don't print widgets. Print vector graphics and text.

Mr.Green
17th March 2015, 15:58
So that means I would have to re-invent the layouting System...?

wysota
17th March 2015, 16:17
I have no idea why you want to print widgets so I cannot answer your question. Usually you'd be printing documents and not widgets.