Limit the usable space in a QFrame

188 views Asked by At

I have a class derived from QFrame. I need to paint something in the bottom area of the QFrame by subclassing paintEvent. This class is then the base class for other classes, which put layouts and widgets on the frame. How can I avoid derived classes to put the widgets over the bottom area which I painted in the base class? Is there a way to limit the usable space in the widget from the base class to all derived classes, without letting them know?

1

There are 1 answers

0
Amartel On BEST ANSWER

Without changing your architecture (which was my first thought), I would recommend something like this:

void QWidget::setContentsMargins ( int left, int top, int right, int bottom )

Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. The margins are used by the layout system, and may be used by subclasses to specify the area to draw in (e.g. excluding the frame).