MacOS X上的QScrollArea透明背景 [英] QScrollArea transparent background on MacOS X

查看:1305
本文介绍了MacOS X上的QScrollArea透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,使 QScrollArea 的内容不绘制背景。

I have a problem with making contents of QScrollArea to not draw a background.

初始图片,当我没有应用样式表:

你可以看到,滚动区域的内容比整体框架更暗。

So here is the initial picture, when I apply no stylesheet: You can see, that the contents of scroll area are darker then the overall frame.

我找到了可以应用于滚动区域的样式表,因此背景是透明的。这里是我使用的样式表:

I have found the stylesheet that I can apply to scroll area, so the background is transparent. Here's the stylesheet I use:

QScrollArea { background: transparent; }
QScrollArea > QWidget > QWidget { background: transparent; }

问题是,当我这样做,scrollarea的滚动条被搞砸了:

Problem is that when I do that, the scrollbar of scrollarea gets messed up:

你看到了吗?

如何使我的样式表不影响滚动条,同时仍然将其应用到 QScrollArea

How can I make my stylesheet not to affect the scrollbar, while still applying it to the QScrollArea? Or what different stylesheet should I apply instead?

推荐答案

尝试为滚动区域视口设置对象名称:

try to set an object name for the scroll area viewport:

pScrollArea->viewport()->setObjectName("myViewport");

然后使用样式表中的hashtag属性在您的屏幕截图中,您的目标是让它们透明):

then address it using the hashtag property in the stylesheet (also add the groupbox since the way I see it in your screenshot, your goal is to make them transparent as well):

QScrollArea, #myViewport, QGroupBox { 
  background: transparent;
}

这篇关于MacOS X上的QScrollArea透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆