pyqt/python-qt5

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

ksallee opened this issue · 0 comments

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