简体   繁体   English

如何在QGraphicsItem上设置不透明度

[英]How set opacity on QGraphicsItem

i have a inherited from QGraphicsScene and QGraphicsItem to create my own classes. 我有一个从QGraphicsScene和QGraphicsItem继承来创建我自己的类。 I use Qt 4.6. 我使用Qt 4.6。

I want to set a specific opacity on each items of my scene. 我想在场景的每个项目上设置特定的不透明度。 I use setOpacity : setOpacity method, but its not the result i hope. 我使用setOpacity: setOpacity方法,但不是我希望的结果。 I want to have for example one item opaque and an other transparent (to see the desktop, or the other application). 例如,我要使一个项目不透明,而使另一个透明(以查看桌面或其他应用程序)。

But if i dont set the opacity of the QGraphicsView to 0.5, i have not the transparancy. 但是,如果我不将QGraphicsView的不透明度设置为0.5,则我没有透明度。 And if the QGraphicsView is set to 0.5, the item is not real opaque. 如果QGraphicsView设置为0.5,则该项目不是真正的不透明。

What should i do ? 我该怎么办 ?

Thanks you. 谢谢。

setOpacity方法是透明的,但仅对图形场景的背景透明,而不对小部件透明,如果要查看桌面,则需要设置小部件(对话框,主窗口等)的不透明性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM