3

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!

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
lancellx
  • 285
  • 1
  • 5
  • 15

1 Answers1

4
auto myScene = scene();

Please read the docs first.

cmannett85
  • 21,725
  • 8
  • 76
  • 119