Does a QGraphicsView take ownership over its associated graphics scene?
I was wondering... if I allocate a graphics scene
QGraphicsScene* scene = new QGraphicsScene();
and associate it with a graphics view
this->ui->graphicsView->setScene(scene);
does the graphics view take ownership of the scene? In开发者_运维技巧 other words, does the graphics view delete the scene in its destructor or should I delete the scene myself?
The answer is no.
That's because Qt makes it possible to display one model (QGraphicsScene
in this case) in many views which is a standard feature of every model/view framework.
Documentation of QGrahpicsView::setScene()
lacks information about what happens to ownership of a scene but the situation is the same as with others views; for example from documentation of void QWebView::setPage ( QWebPage * page )
The parent QObject of the provided page remains the owner of the object. If the current document is a child of the web view, it will be deleted.
精彩评论