Please nominate your Qt Champions for 2021!

Draw lines in QGraphicsView with disabled alpha blending between objects on the same z-index

  • I am working on a 2D graphical application which would display a PCB file read from XML in a QGraphicsView.

    The PCB traces are represented as lines (segments in the XML file). I can read them one-by-one from the XML and create an object derived from the QGraphicsLineItem for each of them. The segments has their RGBA color coded to the XML, including their Z-index.

    My problem is that the overlapping portions of the segments got less alpha blending:

    The alpha blending between segments on the different layers (between red and blue) is good feature, just junctions are problematic on the same layer (blue),

    This is how it should look like:

    As a backup plan I could use drawPolygon to get rid of the overlaps, but it would require to traverse the segments and generate polygons from the overlapping segments.
    This would require much more effort, and if possible I would not like to go down that way.