问题描述
(我使用 Qt :: FramelessWindowHint code>禁用标准边框)
(I used Qt::FramelessWindowHint
to disable standard borders)
我尝试样式表,但 border-radius
和 opacity
似乎对窗口没有任何影响,它只适用于封闭小部件的孩子。
I tried stylesheets, but border-radius
and opacity
doesn't seem to have any effect on the window, it only works on children of the enclosing widget.
我的第二个想法是让窗口完全透明(用 setWindowOpacity
),然后添加一个带圆角的附加小部件(因为 border-radius
在孩子们的工作),然后将所有我的其他小部件到该小部件。但是这不工作,因为 setWindowOpacity
影响所有的孩子(我还没有找到一种方法来改变这种行为)。
My second idea was to make the window fully transparent (with setWindowOpacity
), and then add an additional widget with rounded corners (since border-radius
works on the children), and then group all my other widgets into that widget. But that does not work since setWindowOpacity
affects all children as well (I haven't found a way to change this behaviour).
任何使外部窗口透明我可以想到的方式(像样式表 opacity
)不能正常工作(我只得到一个黑盒子,而不是一个透明窗口)
And any ways to make the outer window transparent I could think of (like stylesheets opacity
) don't work properly (I only get a black box instead of a transparent window)
任何帮助将非常感激。
推荐答案
我有一个类似的问题,我想在一个toplevel小部件绘画,只有被绘的部分出现。 setWindowOpacity更改了绘制部分的不透明度,这是我不想要的。
I had a similar problem where I wanted to paint on a toplevel widget and have only the painted part appear. setWindowOpacity changed the opacity of the painted part, which I didn't want.
this->setAttribute(Qt::WA_TranslucentBackground, true);
更改了没有绘制部分的窗口部件的不透明度。我只是试图折腾一个按钮,也显示完全不透明。因此, 应该能够显示您喜欢的其他儿童。
changed the opacity of the widget without the painted part. I just tried tossing on a button, and that also displays perfectly opaque. So you should be able to display other children however you like.
这篇关于QT4:带圆角的透明窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!