Issues with QPainter::CompositionMode



  • 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.
    alt text

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.