如何重新启用 QGraphicsView 子控件的背景?
将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想在小部件上应用背景颜色,你可以使用:
If you want to apply a background color on a widget you can use maybe: