简体   繁体   English

QT打印质量低下

[英]QT Printing gives low quality

So I'm trying to print a window from my application, and use the following code: 因此,我试图从我的应用程序中打印一个窗口,并使用以下代码:

QPrinter *printer = new QPrinter;

printer->setResolution(1200);

QPrintDialog *printDialog = new QPrintDialog(printer, this);

if (printDialog->exec() == QDialog::Accepted) {

    QPainter p(printer);

    QPixmap pm = QPixmap::grabWidget(this);

    p.drawPixmap(0,0,pm);
}

To test it I export the image to PDF, but what I get is very low resolution file. 为了测试它,我将图像导出为PDF,但是得到的是分辨率很低的文件。 Any idea on how to make a high resolution zoomable image? 关于如何制作高分辨率可缩放图像的任何想法? Cause I am printing a graph which should be readable, as it has some small size values on it. 原因我正在打印一个应该可读的图形,因为它上面有一些小的尺寸值。

QPrinter is a subclass of QPaintDevice , thus you may try to use the following QWidget function which will draw directly at it: QPrinterQPaintDevice的子类,因此您可以尝试使用下面的QWidget函数,该函数将直接在其上绘制:

void QWidget::​render(QPaintDevice * target,...)

Also there's a QPainter version of the same function if you'd like to create QPainter by yourself. 如果您想自己创建QPainter ,也可以使用相同功能的QPainter版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM