0
I am having trouble printing a widget. When executing the code below an error is returned.
#p é uma instancia QPrinter
painter = QPainter(p)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
xscale = p.pageRect().width()/ self.width()
yscale = p.pageRect().height()/ self.height()
scale = min(xscale, yscale)
painter.translate(p.paperRect().center())
painter.scale(scale, scale)
painter.translate((self.width()/2)*-1,(self.height()/2)*-1)
self.render(painter)
painter.end()
The error returned is:
Typeerror: 'Pyside2.QtWidgets.Qwidget.render' called with Wrong argument types: Pyside2.QtWidgets.Qwidget.render(Qpainter) PySide2.QtWidgets.QWidget.render(PySide2.QtGui.QPaintDevice, PySide2.QtCore.QPoint = Default(QPoint), PySide2.QtGui.QRegion = Default(QRegion), PySide2.QtWidgets.QWidget.RenderFlags = Instance(QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren)))
What I don’t understand is, this same code in Pyqt5 works smoothly. Someone could help ?
Obs: I would not like to use pyqt5