0

I am messing around with the print preview of a QGraphicsView instance in Pyside6. I tried many things, but can't get it right.

def onPreview(self):
    printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.HighResolution)
    layout = QtGui.QPageLayout()
    layout.setOrientation(QtGui.QPageLayout.Landscape)
    layout.setPageSize(QtGui.QPageSize.A3)
    printer.setPageLayout(layout)

    preview = QtPrintSupport.QPrintPreviewDialog(printer, self.parent)
    preview.paintRequested.connect(self.handlePaintRequest)
    preview.exec_()

# handle paint request
def handlePaintRequest(self, printer):
    # render QGraphicsView
    self.parent.view.render(QtGui.QPainter(printer))

The snippet works without throwing an error, but the page orientation in the preview is always portrait. Also the page size doesn't work when printing. For sure I handle this in the wrong manner.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
chiefenne
  • 565
  • 2
  • 15
  • 30
  • I do not reproduce the problem, I observe that it is in landscape – eyllanesc Sep 23 '21 at 20:18
  • Thanks for checking. I still have the same behavior. Both on Windows 10 and macOS. My hole application is too big to extract a working example, so I extracted only the two methods here. It seems then, that there are some parts of my application which have an influence. I will do some further investigations. Did you use my methods as they are? – chiefenne Sep 23 '21 at 20:47

0 Answers0