PDA

View Full Version : Composition Modes with multiple QGraphicsItems in a QGraphicsScene



Casper14
14th August 2014, 18:00
I have a QGraphicsScene containing several MyQGraphicsItems, which I subclassed from QGraphicsItem. In the paint event of each MyQGraphicsItem, I draw a QImage. When two or more of these QGraphicsItems are moved over one another, I want the overlapping region to become transparent so that all MyQGraphicsItems in that region are visible. After browsing the internet, it seems that I should be using QPainter::CompositionMode.

I could do this by simply setting the opacity of the MyQGraphicsItems, but then I would have to do the calculations of how many are overlapping myself. Is there any way for me to achieve this using Composition Modes? Most examples set the QPainter's Composition Mode, but my problem is that I want the composition to be computed among all items in the scene.