PDA

View Full Version : Opacity with Qt



Jordison67
31st May 2018, 09:27
Hello.

I would like to change the opacity of a shape in a QgraphicsView by increasing the value in a variable white a horizontal slider but I can not do it. I tried with this code but it does not matter.


qreal opacity = 0.0;
shape->setOpacity(opacity);

Thank you. :)

d_stranz
31st May 2018, 17:10
You probably need to call QGraphicsView::invalidateScene() or QGraphicsView::update() after making the change. If your items are children of other items, you may also have to set opacity propagation flags ( see QGraphicsItem::setOpacity()):


There are two item flags that affect how the item's opacity is combined with the parent: ItemIgnoresParentOpacity and ItemDoesntPropagateOpacityToChildren.

Jordison67
1st June 2018, 08:30
Hello thank you very much but it does not help me much better with a small piece of code I will continue to search...