QWidget framing

122 Views Asked by At

I understand that the co-ordinate system of a widget is local to the widget. 0,0 top left.

I want to draw a frame in the widget, but using the QRect returned by rect() will result in the right and bottom not framed.

There is a method called 'frameGeometry()' however this returns a QRect that is not in the same co-ordinate system as the widget, but in the parents co-orindate system.

Is there a way to get the framing rectangle for the widget in the local co-ordinate system.

I know I can translate the frameGeometry() or simply create a new rectangle:

    QRect(0, 0, width()-1, height()-1);

Is this the proper thing to do?

1

There are 1 best solutions below

3
On BEST ANSWER

The widget most likely has a padding for its canvas which you'll need to subtract from the widget's QRect (which describes the overall space the widget consumes, including padding on all sides) to obtain a rectangle that fits within your widget. Not sure about the specific syntax though.