QT4:带圆角的透明窗口

编程入门 行业动态 更新时间:2024-10-23 11:27:21
本文介绍了QT4:带圆角的透明窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

(我使用 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:带圆角的透明窗口

本文发布于:2023-10-09 18:30:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476447.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:圆角   透明   窗口

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!