Issues with drawing in a QGraphicsScene
I'm working on an animation application right now and I have this cursor that is represented by a QGraphics Object. I'm doing it in PyQt4, but the Qt code is pretty much 1:1 with the C++ version. Here is the code for drawing it:
def init(self, scene=None, parent=None):
points = [
self.cursorPoly = QPolygonF(points)
@ def paint(self, painter, option, widget=None):
# Draw the cursor
# Draw the red line painter.setPen(QPen(Qt.red)) painter.setBrush(QBrush(Qt.NoBrush)) painter.drawLine(QPoint(5, 7), QPoint(5, FrameMark.MARK_HEIGHT))
When I have a QGraphicsView render the object in a scale of (1,1), it looks like this:
This is what it looks like when the QGraphicsView is in a scale of (2,2):
This is what I'm trying to achive:
I'd prefer to do this without loading up the later image, though that is certainly possible. I also don't have any render hints set for the painter for the QGraphicsView.
If I understood you correctly, you want an item that ignores the scaling factor? Try setFlag(QGraphicsItem::ItemIgnoresTransformations) and see if that does what you need.
I should have clarified. The first and third images are completely different. The second is what I want it to look like, except that it's scalled up. The shapes of the while parts are different.
I think it has something to do with the painting coordniate system.
I added the line:
and now it looks how I want it. I find this very odd.