Grzyboo
8th September 2015, 16:33
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);
}
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();
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?
i have such function:
void QTextEditExtended::setHeightByDoc()
{
int iHeight = this->document()->size().height();
this->setMinimumHeight(iHeight);
this->setMaximumHeight(iHeight);
}
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();
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?