void MainWindow::hilightCurrentLine()
{
hilightCurrentLinestart();
QList<QTextEdit::ExtraSelection> extraSelections;//提供一种方式显示选择的文本
QTextEdit::ExtraSelection selection;
QColor lineColor = QColor(Qt::yellow).lighter(160);
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
QTextCursor currentCursor(ui->plainTextEdit->textCursor());//返回当前可见光标副本
// currentCursor.movePosition(12,0,5);
currentCursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,anycnc.LINE);//移动副本光标
ui->plainTextEdit->setTextCursor(currentCursor);//更新可见光标
selection.cursor=ui->plainTextEdit->textCursor();//新光标位置
selection.cursor.clearSelection();//通过设置锚到光标位置清除当前的选择
extraSelections.append(selection);
/*This function allows temporarily marking certain regions in the document with a given color,
specified as selections.
This can be useful for example in a programming editor to mark a whole line of text
with a given background color to indicate the existence of a breakpoint.
*/
ui->plainTextEdit->setExtraSelections(extraSelections);//设置高亮
}