Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issues with QPainter::CompositionMode
Forum Updated to NodeBB v4.3 + New Features

Issues with QPainter::CompositionMode

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 453 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mortbopet
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved