我有以下打印代码:
void Print(QPrinter *printer)
{
QPainter q(printer);
q.setRenderHint(QPainter::HighQualityAntialiasing, true);
q.setPen(QPen(QColor("red")));
q.drawRect(printer->pageRect());
q.drawLine(printer->pageRect().topRight(), printer->pageRect().bottomLeft());
q.setPen(QPen(QColor("blue")));
q.drawRect(printer->paperRect());
q.drawLine(printer->paperRect().topRight(), printer->paperRect().bottomLeft());
}
结果与 QPrintPreviewDialog、渲染 PDF、输出到打印机(HP LaserJet、PdfFactory、PdfCreator)不同。大多数时候,生成的矩形没有纸。怎么做才能使输出与所有打印机相似?