QGraphicsView 是否拥有其关联图形场景的所有权?
我想知道...如果我分配一个图形场景
QGraphicsScene* scene = new QGraphicsScene();
并将其与图形视图关联,
this->ui->graphicsView->setScene(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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是否。
这是因为 Qt 可以在多个视图中显示一个模型(在本例中为 QGraphicsScene),这是每个模型/视图框架的标准功能。
QGrahpicsView::setScene()
的文档缺少有关场景所有权发生情况的信息,但情况与其他视图相同;例如来自void QWebView::setPage ( QWebPage * page )< 的文档/代码>
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 ofvoid QWebView::setPage ( QWebPage * page )