This might be a very uninformed question.
I've been trying to figure out QGraphics*
, and have run into a problem when trying to move an item (a pixmap) relative to or inside of the QGraphicsView
.
class MainWindow(QMainWindow,myProgram.Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.scene = QGraphicsScene()
self.graphicsView.setScene(self.scene)
pic = QPixmap('myPic.png')
self.scene.addPixmap(pic)
print(self.scene.items())
This is the relevant part of the program with an arbitrary PNG
My goal, for example, would be to move the trash-can to the left-most part of the QGraphicsView
.
I tried appending this to the code above:
pics = self.scene.items()
for i in pics:
i.setPos(100,100)
However, it doesn't make a difference, and even if it did, it would be awkward to have to search for it with a "for in".
So my questions are:
How do I access a
QPixmap
item once I have added it to aQGraphicsView
via aQGraphicsScene
. (I believe TheQPixmap
is at this point aQGraphicsItem
, or more precisely aQGraphicsPixmapItem
.)Once accessed, how do I move it, or change any of its other attributes.
Would be very grateful for help, or if anyone has any good links to tutorials relevant to the question. :)