我创建了一个新的QGraphicsItem名为myItem. 在mainwindow.cpp文件中,我有一个QGraphicsScene scene. 在的构造函数中mainwindow:
ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
item = new myItem();
scene->addItem(item);
这工作正常。我可以在现场看到我的物品。但现在我想在myItem.cpp文件中获取场景。我怎样才能做到这一点?
先感谢您!