How to update the size of QTextEdit's document?
i have such function:
void QTextEditExtended::setHeightByDoc()
{
int iHeight = this->document()->size().height();
this->setMinimumHeight(iHeight);
this->setMaximumHeight(iHeight);
}
void QTextEditExtended::setHeightByDoc()
{
int iHeight = this->document()->size().height();
this->setMinimumHeight(iHeight);
this->setMaximumHeight(iHeight);
}
To copy to clipboard, switch view to plain text mode
It's supposed to adjust widget size to text size.
It works fine on signal textChanged, but doesn't work after inserting text by code (height is always 21).
Simple example:
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla");
pText->setHeightByDoc();
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla\r\n");
pText->insertPlainText("blablablabla");
pText->setHeightByDoc();
To copy to clipboard, switch view to plain text mode
The height of pText widget will be 21. However, if i activate textChanged signal by e.g. adding a space into my TextEdit, everything works fine and height is set properly. So, my question is how to update document's size after inserting text by code?
Bookmarks