QPrinter - rectangle coordinates
Hi. I have problem with printing rectangle with QPrinter on real device. Rectangle which I would like to draw is always cliped by a printer. Code below works great when it's export to PDF file.
What I am doing wrong? Please help me. Without this simple task I can not finish my project.
Code:
printer.setFullPage(true);
// printer.setOutputFormat(QPrinter::PdfFormat);
// printer.setOutputFileName("test.pdf");
QRectF rect
= printer.
pageRect();
double margin = rect.width()*0.05;
QRectF body
= QRectF(margin, margin, rect.
width()-margin
*2, rect.
height()-margin
*2);
painter.drawRect(body);
option.setAlignment(Qt::AlignRight);
painter.drawText(body, "test right", option);
painter.drawText(body, "test left");
Re: QPrinter - rectangle coordinates
There doesn't look like anything glaringly wrong from my perspective. I would try looking at QPrinter margin settings
void QPrinter::setPageMargins
as there may be some potential conflict with
void QPrinter::setFullPage
and tweaking your calculated margin constant of 0.05 and seeing what happens to both the pdf and the printer output.
If I wasn't working round the clock for a very crucial deadline I would spend longer on this issue. I will look back to see if I can find anything obvious.
Good Luck
Re: QPrinter - rectangle coordinates
Each printer has a margin where it can't print.
Re: QPrinter - rectangle coordinates
There is at least one bug related to setFullPage() on Windows (if that is what you are using) also:
https://bugreports.qt-project.org/browse/QTBUG-5363
As far as I know it is still outstanding. This bug would cause clipping on the right and bottom of a full page sized box.