QString idString = idTextEdit->textCursor().selectedText().trimmed();//idString为文本编辑区中光标选中高亮内容
if (idString.isEmpty()) //判断是否为空
{
QMessageBox::information(this, "提示", "无法找到");
}
else
{
QTextDocument *document = currentLogEdit->document(); //将文本编辑区转为QTextDocument对象
QTextCursor highLightCursor(document); //高亮光标
QTextCursor cursor(document); //搜索光标
QTextCursor textBlockCursor(document); //整行文本光标
QColor colorText = QColorDialog::getColor( Qt::red, this, "颜色对话框" ); //跳出颜色对话框,以便颜色选择
//开始光标搜索
cursor.beginEditBlock();
while (!highLightCursor.isNull() && !highLightCursor.atEnd())
{
highLightCursor = document->find(idString, highLightCursor, QTextDocument::FindWholeWords);
if (!highLightCursor.isNull())
{
int tempBlock= highLightCursor.b