Search code examples
windowsqtuser-interfaceqpainter

Force widget painting on contentsRect instead of rect


I'm setting contentsMargins for widget and want widget to be painted on contentsRect() instead of rect(). I can do so at paintEvent by setting viewPort and clipRegion, but I don't want to implement paintEvent for every type of widget.

Is it possible to force widget painting on contentsRect instead of rect?

I'm writing analog of mimic creator and want to draw border over each visual component. Just like it's done in Qt creator - when I pick widget at design window, there is a border with resizing points over each widget and I want such border.


Solution

  • Solved. I just created sibling border class for each visual component, implemented moved and resized slots for it so that border resized along with widget, and called stackUnder for each widget so that border painted over each widget. Thanks for collaboration.