QTextEdit *textedit = new QTextEdit();
获取文本框内容:QString qstring = textedit->toPlainText();
设置文本框内容:textedit->setPlainText(qstring);
自动跳到最后一行:
QTextCursor tc =
textEdit->textCursor();
tc.movePosition(QTextCursor::End);
textEdit->setTextCursor(tc);
自动跳到某一行:
QTextCursor tc = textCursor();
int position = document()->findBlockByNumber ( line-1 ).position();
tc.setPosition(position,QTextCursor::MoveAnchor);
setTextCursor( tc );
设置最大行数:textEdit->document()->setMaximumBlockCount(linecnt);
获取行数:textEdit->document()->lineCount();
Qt入门 - QTextEdit,码迷,mamicode.com
原文地址:http://www.cnblogs.com/paullam/p/3700458.html