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 wi
The answer of leemes gave me some insight and I managed to achieve resize of a QTextWidget inside a layout among other controls using custom SizeGrip control. Note that at least one scroll bar should be visible in order to have visible size grip.
It was necessary to reimplement the widget's sizeHint()
method:
QSize MultilineTextEdit::sizeHint() const
{
return size();
}
Then at the end of mouseMoveEvent()
of my SizeGrip widget I added
void SizeGrip::mouseMoveEvent(QMouseEvent * e)
{
// note that this is not the full code of the method
...
// save the old minimum and maximum size of the widget (w) resized by the grip
QSize oldMin = w->minimumSize();
QSize oldMax = w->maximumSize();
w->setFixedSize(nr.size()); // nr is the new rect of the widget
w->setMinimumSize(oldMin);
w->setMaximumSize(oldMax);
}
The SizeGrip widget was inspired by the QSizeGrip class which operates on the top level parent window directly. SizeGrip operates on its direct parent widget instead.