Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPrinter: PdfFormat and transparency

QPrinter: PdfFormat and transparency

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fober
    wrote on last edited by
    #1

    Hi,

    I'm exporting a QGraphicsView to various file formats: actually pdf and the image formats supported by QImage. My problem is that I loose my items transparency when exporting to pdf although the code is very similar.
    Here is the image export code:

    @QImage image(size, QImage::Format_ARGB32_Premultiplied);
    image.fill( view->backgroundBrush().color().rgba() );
    paintOnDevice (&image, view);
    image.save( fileName );
    @
    and here is the pdf export
    @QPrinter printer (QPrinter::HighResolution);
    printer.setOutputFileName( QString(fileName) );
    printer.setOutputFormat( QPrinter::PdfFormat );
    printer.setPaperSize( size , QPrinter::Point );
    paintOnDevice (&printer, view);
    @
    where paintOnDevice is simply:
    @QPainter painter(device);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
    view->render( &painter );
    painter.end();
    @
    and where view is a QGraphicsView pointer.

    I'm using Qt 4.7.0 and I get the same results on Mac OS X and Ubuntu Maverick 64bits. On windows, I'm using an older version (4.6.2) but I get the same results.
    Any help would be appreciated

    Dominique

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved