3
votes

I create a new QGraphicsItem named myItem. And in the mainwindow.cpp file I have a QGraphicsScene scene. In the constructor of mainwindow:

ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
item = new myItem();
scene->addItem(item);

This works fine. I can see my item on the scene. But now I want to get the scene in myItem.cpp file. How can I do this?
Thank you in advance!

1

1 Answers

4
votes
auto myScene = scene();

Please read the docs first.