Important: Please read the Qt Code of Conduct -

Invalidating / alpha smoothing

  • hey guys, I have the following problem: I made a component (using pure QML, no C++), which draws it's contents using Canvas. It consists mostly of an arc, which is drawn with smoothed edges, while the rest of the component has to be transparent.

    So far so good. But: if the component redraws, it paints itself over and over again, which gradually corrupts the semi-transparent pixels at the arc's edges. If a 50% transparent pixel is applied ontop of itself (having been applied to some background previously), the result will be 25% transparency, instead of 50%.

    In other words: if you have a component that's not fully opaque, it is crucial to invalidate the covered background before repeatedly drawing the actual graphics of the component, otherwise alpha-blended smoothed edges will not work.

    How is this supposed to work out? I found no way to invalidate a certain region covered by a component...

    thanks a lot,

  • Hi Wolfgang,

    The function you are looking for is clearRect:

  • Thanks a lot! That's exactly what I need.

Log in to reply