Printing QPixmap. Resolution problem

  • Hello!

    I'm trying to print a QPixmap with QPrinter but it appears in very low resolution. I don't know how to fix it.
    At first, I have a function that initializes the QPrinter and the QPrintPreviewDialog, and put this in a layout. Then, in a second function, I draw the pixmap with a QPainter. When I execute that, the resolution of the QPixmap is very very low.

    Any idea?

    Here is my code:

    void report_tab::showPrint() {
        printDialog = new QPrintPreviewDialog(&printer);
        connect(printDialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(print(QPrinter*)));
    void report_tab::print(QPrinter *p) {
        QPainter painter;
        screenshot = screenshot.scaled(p->pageRect().width(), p->pageRect().height(), Qt::KeepAspectRatio);
        painter.drawPixmap(0, 0, screenshot);

    Thank you very much!

  • I solved the problem. I tried to paint a QImage instead of a QPixmap and it works successfully!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.