QT QPlainTextEdit 获取某行内容

#include <QTextBlock>

QString str;

/* 行数 */
str = QString::number(ui->plainTextEdit->document()->lineCount());
QMessageBox::information(this, "information", str);

/* 输出某行内容 */ 
str = ui->plainTextEdit->document()->findBlockByLineNumber(2).text(); 
QMessageBox::information(this, "information", str);


 
 

你可能感兴趣的:(QT QPlainTextEdit 获取某行内容)