Professional Documents
Culture Documents
I have some problems using QPdfWriter and QPainter to print a part of a QDialog.
In this GUI I have incorporated an "overview". In practice, it summarize all the inputs and
outputs, in a QDialog. This QDialog contains a scrollArea, defined at the centralWidget.
(screen right there : https://imgur.com/a/iiCGnaX )
So my researches make me use this kind of coding to grab the scrollArea, and to print it in
PDF :
QPdfWriter pdfWriter(filePath);
pdfWriter.setResolution(100);
QPainter painter;
painter.begin(&pdfWriter);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.drawPixmap(0,0,screenshotPDF);
painter.end();
In case of, the content of the screen area is completely manually made (It has the dimension
of an A4 paper, and I put the QGroupBox without layout).
Thing is the result doesn't have a good quality. I tried to play on the renderHint, on the
resolution, but I don't find something quite good.
screen here : https://imgur.com/a/Gh3LHPM.
As you can see, it's "blurry" and not neat.
I guess I'm doing something wrong, but all that I try didn't work really well (for example, if I just
change the "setResolution" line to N*100, I end up with something N time too small/High)
That's the first time I post here, I hope my question is appropriate, also I wanted to thank you
for this forum which help a lot the neophyte I am.
Imra'
Share Improve this question edited May 23 '18 at 7:15 asked May 22 '18 at 13:10
Join Stack
FollowOverflow to learn, share knowledge, and build your career. Imra Sign up
11 2
https://stackoverflow.com/questions/50468588/qt-printing-a-qdialog-in-pdf-format-quality-issues 1/2
7/9/2021 Qt, printing a QDialog in PDF format, quality issues - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career. Sign up
https://stackoverflow.com/questions/50468588/qt-printing-a-qdialog-in-pdf-format-quality-issues 2/2