子类化 QGraphicsItemGroup

发布于 2024-08-30 18:05:49 字数 355 浏览 4 评论 0原文

我的系统具有从 QGraphicsWidget 派生的类。我在 QGraphicsScene 的布局中管理派生类对象。现在我需要一个包含两个或多个 QGraphicsWidget 的复合项目,并且我还需要将该项目放入我的布局中。所以我选择 QGraphicsItemGroup 并像这样编写我的类。

class CompositeItem : public QGraphicsItemGroup,public QGraphicsLayoutItem
{   
   ...  
};

我只再次实现了 sizeHint 函数。 当将 CompositeItem 实例添加到布局时,它不会显示。 可能是什么原因造成的?我哪里做错了?

I have system that has classes derived from QGraphicsWidget. I manage derived class objects in layouts on QGraphicsScene. Now I need a compound item that contain two or more QGraphicsWidget in it and also I need to put that item inside my layout. So I choose QGraphicsItemGroup and write I class like this.

class CompositeItem : public QGraphicsItemGroup,public QGraphicsLayoutItem
{   
   ...  
};

I only implemented sizeHint function again.
When add CompositeItem instance to layout it does not shown.
What may cause this? Where I made wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮茶煮酒煮时光 2024-09-06 18:05:49

添加到布局后,在 QGraphicsItemGroup 或 QGraphicsWidgets 上调用 show() 。

Call show() on either the QGraphicsItemGroup or QGraphicsWidgets after adding to the layout.

挖个坑埋了你 2024-09-06 18:05:49

将 setGraphicsItem( this ) 添加到您的构造函数中。

Add setGraphicsItem( this ) to your constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文