修改外部模型
我有一个树(场景图),我想通过 QTreeView 显示它。 SceneGraphModel
是 QAbstractItemModel
的子类,它实现了显示树所需的所有方法,并使用指向 的指针分发
。QModelIndexS
他们引用的节点
在我尝试直接操作 SceneGraph
之前,这种方法效果很好。这导致了段错误,因为树视图尝试使用 QModelIndex
中现在无效的 Node
指针。
我是否必须通过 SceneGraphModel
对 SceneGraph
进行所有操作?有办法解决这个问题吗?
I have a tree (scene graph) that I want to display through QTreeView
. SceneGraphModel
is a sub-class of QAbstractItemModel
and implements all methods necessary to display the tree and hands out QModelIndexS
with a pointer to the Node
they reference.
This worked pretty well until I tried to manipulate the SceneGraph
directly. This caused a segfault because the treeview tried to use the now invalid Node
Pointers in the QModelIndex
.
Do I have to do all manipulation of the SceneGraph
through the SceneGraphModel
? Is there a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论