Qt - QTextEdit

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();

 

posted @ 2014-04-30 00:22  paullam  阅读(1316)  评论(0编辑  收藏  举报