PDA

View Full Version : Limit Amount of Text in a QTextEdit



johnmauer
9th January 2010, 20:14
I need to limit the amount of text in a QTextEdit so that the user can't go beyond the size of visible space, that is, no scrolling. If the user tries to do so, i need to emit a signal to post a limit message.

Stopping scrolling leads to a very poor document response, both for the last line and the cursor. Limiting the number of blocks can not overcome long lines. Is there a good way to do this? Thanks.

boudie
10th January 2010, 16:53
Take a look at
QRect QPainter::boundingRect ( const QRect & rectangle, int flags, const QString & text )

With that function you can check at every keyboard input of it will exceed your preferred size.