A QWidget like QTextEdit that wraps its height automatically to its contents?

Viewed 11196

I am creating a form with some QTextEdit widgets.

The default height of the QTextEdit exceeds a single line of text and as the contents' height exceeds the QTextEdit's height, it creates a scroll-bar to scroll the content.

I would like to override this behaviour to create a QTextEdit that would rather wrap its height to its contents. This means that the default height would be one line and that on wrapping or entering a new line, the QTextEdit would increase its height automatically. Whenever the contents height exceeds the QTextEdit's height, the latter should not create a scroll bar but simply increase in height.

How can I go about doing this? Thanks.

2 Answers
Related