如何在 QGraphicsView 上锚定 QGraphicsWidget/Item(使它们静态)

发布于 2024-09-18 09:06:55 字数 486 浏览 1 评论 0原文

我想做一个像平视显示器这样的东西。我有一个带有巨大 QPixmapQGraphicsScene,我将其添加到了一个小得多的 QGraphicsView 中。现在我需要添加一些控制元素,例如 QLabelQPushButtonQGraphicsEllipseItem。我认为这不是问题。我发现这个有用的页面图形视图类。但是我如何将这个控制元素锚定到视图上,或者更好地说我如何不锚定它们?当我拖动QPixmap时,我不希望HUD随着QPixmap一起移出QGraphicsView。 我需要做什么,才能解决这个问题。希望有人能帮助我。

I want to make something like a hud. I have a QGraphicsScene with a huge QPixmap, that I added to a much smaller QGraphicsView. Now I need to add some control elements, like QLabel, QPushButton and QGraphicsEllipseItem. That's, I think, is not a problem. I found this helpful page Graphics View Classes. But how do I anchor this control elements to the View or maybe better said how do I not anchor them? When I drag the QPixmap, then I don't want that the hud is moving with the QPixmap out of the QGraphicsView.
What do I need to do, to solve this problem. Hope someone can help me.

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

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

发布评论

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

评论(1

柳絮泡泡 2024-09-25 09:06:55

您应该只需要创建小部件并在构造函数中指定 QGraphicsView ,如下所示:

QPushButton *button1 = new QPushButton(view);

You should just have to create your widgets and specify the QGraphicsView in the constructor like this:

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