[Solved] Why might ItemClipsChildrenToShape fail?



  • I use the flag QGraphicsItem::ItemClipsChildrenToShape a lot. I now have a situation where the flag simply is ignored, and I don't know why.
    Here is what I checked so far, did I miss anything?

    • The child I want clipped is indeed an (indirect) child of the item with ItemClipsChildrentoShape set
    • The flag is still set right before I start painting
    • The shape of the item is correct, and would clip where I want it to be clipped

    I stepped through the drawItems code a bit, and noticed I never entered the ifs related to this kind of clipping. It looks a though the flag is considered "false" although I have set it to true, and the flags() return it as true.

    I'd post code, but it's multiple files and I would first have to find out what causes the behavior (because a simple example will work as expected). If you have any suggestions about something specific I should post, please let me know.

    EDIT:
    Solved. I shot my own foot.
    All that ItemClipsChildrenToShape does is to set the clipping region of the painter prior to calling paint. If I then replace the clipping e.g. by calling setClipRect, all that is lost.


Log in to reply
 

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