Trying To Get Just "x" Coordinate From Pos() Method Python
I'm currently having an issue getting just the x position of the cursor so I can place a marker on that x and y location. I'm using QGraphicsScene and view to create this circle ob
Solution 1:
I'm not 100% clear what your problem is (are you getting an exception? Does it run but you get unexpected output?), but this line looks like the culprit:
self.x,y = self.cursor.pos()
This will create x as an attribute of self, and then create a local variable y that has no association with self at all. If you want both of them to be attributes of self, do
self.x, self.y = self.cursor.pos()
If you were getting an error while trying to do QGraphicsEllipseItem(self.x,self.y,10,10), this would explain why - self.y didn't exist, so it would give you an AttributeError.
Post a Comment for "Trying To Get Just "x" Coordinate From Pos() Method Python"