如何重新启用 QGraphicsView 子控件的背景?

发布于 2025-01-13 08:55:36 字数 566 浏览 3 评论 0原文

将 QGroupBox 和 QFrame 等 QWidget 添加到 QGraphicsView 上设置的布局时,这些小部件没有背景。各种看起来应该重新启用它的东西都不起作用。 (例如,setAutoFillBackground(true);。)

是否有某种方法可以让小部件再次绘制其背景?

QFrame*         mycw    = new QFrame();
QHBoxLayout*    loMain  = new QHBoxLayout();
    loMain->addWidget( mycw );
    pView = new QGraphicsView();
    pView->setLayout( loMain );
    pView->showFullscreen();

编辑:这可能与 opengl 或其他东西有关。我试图解决这个问题,通过使两个小部件对等 - 并使用父级的 resizeEvent 来安排它们,根本没有布局。它仍然发生!如果它绘制在 QGraphicsView 的前面,那么它最终没有背景。

我将不得不更深入地挖掘。 :(

When adding QWidgets such as QGroupBox and QFrame to a layout set on QGraphicsView, those widgets have no background. Various things that seem like they should re-enable it, do not work. (E.g., setAutoFillBackground(true);.)

Is there some way to get the widgets to draw their background again?

QFrame*         mycw    = new QFrame();
QHBoxLayout*    loMain  = new QHBoxLayout();
    loMain->addWidget( mycw );
    pView = new QGraphicsView();
    pView->setLayout( loMain );
    pView->showFullscreen();

Edit: This may have something to do with opengl or something. I have tried to work around it, by making the two widgets peers - and using the resizeEvent of the parent to arrange them with no layout at all. And it still happens! If it's drawn in-front of the QGraphicsView, it ends up with no background.

I will have to dig deeper. :(

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

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

发布评论

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

评论(1

拥醉 2025-01-20 08:55:36

如果你想在小部件上应用背景颜色,你可以使用:

widget->setStyleSheet("background-color: yellow");

If you want to apply a background color on a widget you can use maybe:

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