
Originally Posted by
munna
Hi,
I have a QTextEdit with fixed width and wrap mode set to setLineWrapMode(QTextEdit::WidgetWidth);
Now, when user edits the text in this box, i need to increase the height of this QTextEdit so that the vertical scrollbar never appears and all the text entered could be seen.
I have connected a slot to the textChanged() signal but not sure how exactly can the height be calculated.
Any ideas on how I can implement this one?
Thanks a lot.
Use virtual int heightForWidth ( int w ) const . Give the width as argument and get the height. then use resize(int width, int height).
Something like this
void myClass::slotTextChanged()
{
int height = textEdit->heightForWidth(textEdit->width());
textEdit->resize(textEdit->width(), height);
}
void myClass::slotTextChanged()
{
int height = textEdit->heightForWidth(textEdit->width());
textEdit->resize(textEdit->width(), height);
}
To copy to clipboard, switch view to plain text mode
Bookmarks