Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Invalidating / alpha smoothing

    QML and Qt Quick
    2
    3
    527
    Loading More Posts
    • 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.
    • W
      woolfman007 last edited by

      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,
      Wolfgang

      1 Reply Last reply Reply Quote 0
      • sletta
        sletta last edited by

        Hi Wolfgang,

        The function you are looking for is clearRect: http://qt-project.org/doc/qt-5/qml-qtquick-context2d.html#clearRect-method.

        1 Reply Last reply Reply Quote 0
        • W
          woolfman007 last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post