Hi. I have a QPixmap object loaded from a PNG file with transparency. This pixmap is displayed onto a QGraphicsScene via an overloaded QGraphicsItem.
I want the item to be more "lighty" when it is selected. I'm doing something like this:
painter->fillRect(boundingRect(), Qt::gray);
painter
->setCompositionMode
(QPainter::CompositionMode_Overlay);
QRect rect
= boundingRect
().
toRect();
painter->drawPixmap(rect, myPixmap);
painter->fillRect(boundingRect(), Qt::gray);
painter->setCompositionMode(QPainter::CompositionMode_Overlay);
QRect rect = boundingRect().toRect();
painter->drawPixmap(rect, myPixmap);
To copy to clipboard, switch view to plain text mode
It's working, but the problem is that the transparent region of the pixmap becomes "grayed" too ...
How can i draw the gray color just on the real icon, not touching the transparent region of the pixmap ?
Bookmarks