Limit Amount of Text in a QTextEdit
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.
Re: Limit Amount of Text in a QTextEdit
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.