QPainter in PyQt
-
Hi guys, I kinda new with ptqt and seem to have the following error when I try to create a simple QPaint program. Does anyone know how can I "active" my Painter? Help is much appreciated. Thanks you in advance.
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setPen: Painter not activedef paintEvent(self, event = None):
paint = QPainter()
paint.setRenderHint(QPainter.Antialiasing)
paint.setPen(QtGui.QPen(QtGui.QColor(Qt.green)))
paint.drawEllipse(300,300,70,70) -
def paintEvent(self, event = None):
paint = QPainter()
paint.begin()
paint.setRenderHint(QPainter.Antialiasing)
paint.setPen(QtGui.QPen(QtGui.QColor(Qt.green)))
paint.drawEllipse(300,300,70,70)
paint.end()I initially had the paint.begin() statement however when i implement that statement I would have the following error:
TypeError: QPainter.begin(QPaintDevice): not enough arguments -
What is considered as a QPaintEvent argument?
-
Hi,
My PyQt is a bit rusted but IIRC you need something like:
@
paint = QPainter(self)
@Otherwise you are trying to paint on nothing so it won't work.
Hope it helps