修改外部模型

发布于 2024-12-25 12:51:31 字数 394 浏览 3 评论 0原文

我有一个树(场景图),我想通过 QTreeView 显示它。 SceneGraphModelQAbstractItemModel 的子类,它实现了显示树所需的所有方法,并使用指向 的指针分发 QModelIndexS他们引用的节点

在我尝试直接操作 SceneGraph 之前,这种方法效果很好。这导致了段错误,因为树视图尝试使用 QModelIndex 中现在无效的 Node 指针。

我是否必须通过 SceneGraphModelSceneGraph 进行所有操作?有办法解决这个问题吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文