Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-1758

Printing areas with semi transparency results in incorrectly printed lines

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.3.3
    • GUI: Printing
    • None
    • 19afb1a5e9580ee46442717012ebef054abe1e21

    Description

      The example below demonstrates the problem on MacOSX and Windows. The output of the PDF generator is correct. On Windows, the grid-lines are not dotted, and thinner within the bounding rectangle of the semi-transparent polygon. On MacOSX the grid-lines are never dotted, but thicker in the area of the bouding rectangle. Removing the polygon or giving it a fully opaque color prints the grid lines consistently on both Mac and Windows, but still not dotted on Mac OSX.

      #include <QtGui>
      #include <QtCore>

      int main(int argc, char* argv[])
      {
      QApplication app(argc, argv);
      QGraphicsScene scene;
      QGraphicsView view;
      view.setScene(&scene);

      QPen solid(Qt::black);
      solid.setWidth(1.0);
      QPen pointLine(Qt::black);
      pointLine.setWidth(0.0);
      pointLine.setStyle(Qt::DotLine);
      scene.addRect(0, 0, 400, 400, solid);
      scene.addLine(0, 80, 400, 80, pointLine);
      scene.addLine(0, 160, 400, 160, pointLine);
      scene.addLine(0, 240, 400, 240, pointLine);
      scene.addLine(0, 320, 400, 320, pointLine);
      scene.addLine(80, 00, 80, 400, pointLine);
      scene.addLine(160, 00, 160, 400, pointLine);
      scene.addLine(240, 00, 240, 400, pointLine);
      scene.addLine(320, 00, 320, 400, pointLine);
      QVector<QPointF> polygonPoints = QVector<QPointF>() << QPointF(40, 40)
      << QPointF(120,360) << QPointF(280,360);
      QColor polygonFillColor = Qt::red;
      polygonFillColor.setAlpha(30);
      QPen polygonPen(Qt::red);
      polygonPen.setWidth(1.0);
      QPolygonF polygon(polygonPoints);
      QBrush polygonBrush(polygonFillColor);
      scene.addPolygon(polygon, polygonPen, polygonBrush);

      view.show();

      QRectF bounds = scene.itemsBoundingRect();

      { QPrinter pdfPrinter(QPrinter::HighResolution); pdfPrinter.setOutputFormat(QPrinter::PdfFormat); pdfPrinter.setOutputFileName("output.pdf"); QRectF pdfTargetRect; pdfTargetRect.setSize(bounds.size() * pdfPrinter.resolution() / 100); QPainter pdfPainter(&pdfPrinter); scene.render(&pdfPainter, pdfTargetRect, bounds); }

      QPrinter printer(QPrinter::HighResolution);
      QPrintDialog printDlg(&printer, &view);
      if (printDlg.exec())

      { QRectF targetRect; targetRect.setSize(bounds.size() * printer.resolution() / 100); qDebug() << printer.logicalDpiX() << printer.logicalDpiY(); qDebug() << printer.physicalDpiX() << printer.physicalDpiY(); QPainter painter(&printer); scene.render(&painter, targetRect, bounds); }

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kjernase Trond Kjernåsen (Inactive)
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes