Qt-interest Archive, March 2002
limit the lines number in QTextEdit ?
Message 1 in thread
Hi.
I would like to limit the lines number in QTextEdit (Qt 3.x) (for a chat
cljent, you know, the lines number i potentially endless growing...)_.
However, I don't see any obvious way to do it, unlike in Qt 2.x with the
setMaxLines() method of the QMultiLineEdit class. But now, this class
and this method are obsolete... Could you tell me an easy way to do it
(if possible, without storing the text in a linked list or something
like that...)
Thanking you in advance...
Message 2 in thread
At 12:01 PM 3/12/02 +0100, Arnaud.Arzuffi wrote:
>I would like to limit the lines number in QTextEdit (Qt 3.x) (for a chat
>cljent, you know, the lines number i potentially endless growing...)_.
>However, I don't see any obvious way to do it, unlike in Qt 2.x with the
>setMaxLines() method of the QMultiLineEdit class. But now, this class
>and this method are obsolete... Could you tell me an easy way to do it
>(if possible, without storing the text in a linked list or something
>like that...)
I use the following:
if(textEdit->numLines() > maxLines )
{ textEdit->removeLine(0);
}
textEdit->insertLine(QString("new text"),-1);
textEdit->setCursorPosition(textEdit->numLines(),0,FALSE);
as long as you don't have too many lines it works fine.