QTextEdit 读取一行 删除一行
建议使用QPlainTextEdit控件的setMaximumBlockCount(int)函数控制总行数,并且使用setUndoRedoEnabled(false),可以有效控制内存增长。
QPlainTextEdit控件的maximumBlockCount : int属性说明如下:
此属性保留文档中块的限制。
指定文档可能具有的最大块数。如果文档中有更多使用此属性指定的块,则会从文档开头删除这些块。
负值或零值指定文档可以包含无限量的块。
默认值为0。
请注意,设置此属性将立即对文档内容应用限制。设置此属性也会禁用撤消重做历史记录。
maximumBlockCount : int
This property holds the limit for blocks in the document.
Specifies the maximum number of blocks the document may have. If there are more blocks in the document that specified with this property blocks are removed from the beginning of the document.
A negative or zero value specifies that the document may contain an unlimited amount of blocks.
The default value is 0.
Note that setting this property will apply the limit immediately to the document contents. Setting this property also disables the undo redo history.
Access functions:
int maximumBlockCount() const
void setMaximumBlockCount(int maximum)
QPlainTextEdit控件的undoRedoEnabled : bool属性说明如下:
此属性保存是否启用了撤消和重做
如果此属性为true,并且存在可以撤消(或重做)的操作,则用户只能撤消或重做操作。
默认情况下,此属性为true。
undoRedoEnabled : bool
This property holds whether undo and redo are enabled
Users are only able to undo or redo actions if this property is true, and if there is an action that can be undone (or redone).
By default, this property is true.
Access functions:
bool isUndoRedoEnabled() const
void setUndoRedoEnabled(bool enable)