Results 1 to 3 of 3

Thread: QPixmap and printer resolution

  1. #1
    Join Date
    Jun 2006
    Location
    Stuttgart
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPixmap and printer resolution

    I want to print a pixmap with high resolution. Unfortunately, when i make QPrinter p(QPrinter::highResolution) or (QPrinter:rinterResolution) the pixmap is too small on the paper. Has someone a idea?

    My code:

    QPrinter p;

    QPrintDialog qp (&p, this);
    if (qp.exec() == QDialog::Accepted)
    {
    qDebug () << "printerDialog";
    QRect rect (0, 0, 288, 180);
    QPixmap qpm = QPixmap::grabWidget(cardWidget, rect);

    QPainter painter;
    qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
    painter.begin (&p);
    painter.drawPixmap (0, 0, qpm);
    painter.end();
    }

    Thanks a lot.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap and printer resolution

    Override the resolution with QPrinter::setResolution( int dpi ).
    You can use 720 dpi, and should result in a good picture quality.

    Also, be careful when scaling the pixmaps, because the process is not lossless.

    Regards

  3. #3
    Join Date
    Sep 2007
    Posts
    31
    Thanked 1 Time in 1 Post

    Default Re: QPixmap and printer resolution

    It's too late, but just to notice, you should use:
    Qt Code:
    1. qmp = qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
    To copy to clipboard, switch view to plain text mode 
    instead of:
    Qt Code:
    1. qpm.scaled(p.pageRect().width(), p.pageRect().height(), Qt::KeepAspectRatio);
    To copy to clipboard, switch view to plain text mode 
    Otherwise your qpixmap won't be rescaled!

    Regards,
    Oscar

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.