QWidget背景颜色没有完全覆盖QWidget
使用 Qt Creator,我将 QWidget 的背景属性设置为黑色。然而,QWidget 的某些部分,更具体地说,在 QFrames/QGroupBoxes 之间仍然采用系统的默认颜色。
现在,我认为 QFrames 和 QGroupBoxes 也需要将其背景属性设置为黑色,但它不起作用。我也尝试过将边框颜色设置为黑色,但它不起作用,因为默认情况下边框、边距设置为 0。
QWidget { background: black; }
对此问题有什么建议吗?
编辑
QWidgets 放置在 QMdiArea 中。但是,如果我将其设为 QWindow,它就可以工作。但是,我希望 QWidget 位于 QMdiArea 中。另外,如果我只按原样显示 QWidget,则上面提到的空间是透明的。
Using Qt Creator, I have set a QWidget's background property to black. However, some parts of the QWidget, more specifically, between QFrames/QGroupBoxes are still in its system's default color.
Now, I thought that the QFrames and QGroupBoxes need to have its background property set to black too, but it did not work. I have also tried setting the border-color to black, but it does not work, since by default borders, margins are set to 0.
QWidget { background: black; }
Any advice on this issue?
EDIT
The QWidgets are placed in QMdiArea. However, if I make it a QWindow, it works. However, I want the QWidgets to be in the QMdiArea. Also, if I just show the QWidgets as it is, the spaces that I have mentioned above are transparent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您在另一个小部件中有一些小部件,并且将包含的小部件设置为黑色,但它们之间的空间不是黑色的。如果是这种情况,很可能是因为您在包含的小部件中有一个布局,它在每个包含的小部件之间分配空间。小部件之间的空白区域将使用包含小部件的背景颜色绘制。
It sounds like you have some widgets within another widget, and are setting the contained widgets to be black, but then the space between them is not black. If that is the case, it is likely because you have a layout in the containing widget, which allocates space between each contained widget. The empty space between widgets will be drawn with the containing widget's background color.
找到了解决方案。看来你需要在 QMdiSubWindow 设置背景颜色,而不是在 QWidget 。不知道为什么,但似乎符合逻辑。
Found out the solution. It seems that you need to set the background color at the QMdiSubWindow, not at QWidget. Don't know why, but it seems logical.