I have a custom QTextEdit widget that has it’s own resize grip in the corner. I can resize the text widget fine, however the layout it is inside does not change with the resizing of the text edit.
Is there a way to tell the managing layout to recalculate itself based on the independent change in size in one of its widgets?
The layout respects the
sizeHint()andminimalSizeHint()of its children (not theirsize()). So you should reimplement these two virtual methods and return the size you want to force. Whenever your size hint changes, you should callupdateGeometry()on your own widget to trigger an update of the layout where the widget is placed in.See documentation:
So, to force a minimum size of your widget, implement
minimumSizeHint()by returning your minimum size; to force a fixed size, implement both by returning the same size.I also recommend reading the following section in the documentation page "Layout Management":
Update (see comments):
You can also force a size (or height / width only) by calling:
These methods simply set the size hints to the given value and call
updateGeometry()AFAIK. But maybe they do a little bit more since (as seen in the comments) this was the only way I could find to solve the problem here.