Hi,

I want to change the height and width of the text edit as user types in it. To do that i use maximumViewportSize() and then I set the height and width accordingly. Also, I have set the scroll bar policy to always off for both the scrollbars. I am not getting the expected results.

On every key event i do the following.

Qt Code:
  1. QSize s = maximumViewportSize();
  2.  
  3. setFixedWidth(s.width());
  4. setFixedHeight(s.height());
To copy to clipboard, switch view to plain text mode 

Everytime I call this the maximumViewportSize() decreses but it should increase when some text is added. Eventually the size becomes negative and i get the following message in my debugger.

QWidget::setMinimumSize: The smallest allowed size is (0,0)
QWidget::setMaximumSize: (/QTextEdit) Negative sizes (49,-4) are not possible

Can someone please tell me where am i going wrong ?

Thanks a lot.