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

Printing on Mac always prints in ColorMode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • Some future release
    • 4.8.5, 5.2.1
    • GUI: Printing
    • None
    • MacBook Air 2011, HP LaserJet CP1515n
    • macOS

    Description

      Using QPrinter on Mac always prints in color, even if I use QPrinter::setColorMode to force it to GrayScale. I am using a HP LaserJet CP1515n printer, but some of my customers reported the same problem on other printers.

      I managed to reproduce the problem in a widget based sample application by inserting the below paint code into the widget. When using the native print dialog changing the color mode in the dialog works as expected.

      Is there any way to work around this problem?

      void Widget::paintEvent(QPaintEvent *event)
      {
         QPainter painter(this);
         painter.fillRect(0, 0, 200, 200, Qt::red);
      
         static bool printed = false;
      
         if (!printed)
         {
            printed = true;
      
            // Forcing printing in GrayScale, but still prints in color on Mac
            QPrinter printer(QPrinterInfo::availablePrinters()[1]);
            printer.setColorMode(QPrinter::GrayScale);
            QPainter painter;
            painter.begin(&printer);
            painter.fillRect(0, 0, 200, 200, Qt::red);
            painter.end();
         }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              johnlayt John Layt
              zottel78 Fabian Roeken
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes