pyqt / python-qt5

Unofficial PyQt5 via PyPI for Python 2.7 64-bit on Windows
GNU General Public License v3.0
280 stars 77 forks source link

`QMacCGContext:: Unsupported paint device type 4` from a shell in MacOS #66

Open ksallee opened 3 years ago

ksallee commented 3 years ago

When running this code from a shell on MacOS:

        from sgtk.platform.qt5 import QtPrintSupport
        QPrinter = QtPrintSupport.QPrinter
        # Set up the printer
        printer = QPrinter(QPrinter.HighResolution)
        printer.setPaperSize(QPrinter.A4)
        printer.setResolution(300)

        # Note: this will set the format to PdfFormat.
        printer.setOutputFileName(tempfile.gettempdir() + "foo.pdf")
        # Use the system implementation rather than the one coming with Qt.
        printer.setOutputFormat(QPrinter.NativeFormat)
        painter = QtGui.QPainter()
        painter.begin(printer)
        # Some code to paint things here.
        painter.end()

It throws the following error: QMacCGContext:: Unsupported paint device type 4

It doesn't seem to impact the output, the document works fine.

I have another setup where this is run from another app that belongs to a framework, and the error is not thrown, and I can't find the difference between the two setups.

I tried digging through the C++ code but could not find why this was thrown, although I found where: https://code.woboq.org/qt5/qtbase/src/gui/painting/qcoregraphics.mm.html#393