Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Issues with QPainter::CompositionMode
mortbopet last edited by
I am currently experiencing an issue with setting the composition mode of a QPainter, with it giving me results which i do not expect.
Filled objects are drawn on a QGraphicsScene, which has its background set to transparent.
In this scene, various lines are drawn (in the paint function of the Lines class). I'd like to set these lines to have QPainter::CompositionMode_DestinationOver ie, draw the shapes above the lines.
The issue is, that setting this composition mode results in the lines being completely gone from the scene. Initially i thought that it mistook the background of the scene as a destination source, and drew the lines beneath these, but with a transparent background set, i do not see why these lines are drawn incorrectly.
Snippet of the paint function for the Line object:
void Line::paint(QPainter* painter, ...); ... painter->setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter->setBrush(Qt::black); painter->setCompositionMode(QPainter::CompositionMode_DestinationOver); painter->drawPolyline(QPolygonF(line));
Removing the setCompositionMode line above yields the result from the first image.
Any help would be greatly appreciated