I have working code to highlight text in a QTextEdit widget, code follows:

//------------------------------------------------------------------------------
void MainWindow::HighLightText(QString foundText)
{
QTextEdit *editCell = new QTextEdit(tableWidgetFindings->item(SearchRow.at(NextSearch), SearchColumn.at(NextSearch))->text());
editCell->setReadOnly(true);
editCell->setTextInteractionFlags(Qt::NoTextInteraction);
//editCell->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);
//editCell->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff );
tableWidgetFindings->setCellWidget(SearchRow.at(NextSearch), SearchColumn.at(NextSearch), editCell);
QTextCursor highlightCursor(editCell->document());
QTextCharFormat colorFormat(highlightCursor.charFormat());
colorFormat.setForeground(Qt::red);

while (!highlightCursor.isNull() && !highlightCursor.atEnd()){
if (wholeWord && CaseSensitive){
highlightCursor = editCell->document()->find(foundText, highlightCursor, QTextDocument::FindWholeWords | QTextDocument::FindCaseSensitively);
}
else{
if (wholeWord){
highlightCursor = editCell->document()->find(foundText, highlightCursor, QTextDocument::FindWholeWords );
}
else{
if (CaseSensitive){
highlightCursor = editCell->document()->find(foundText, highlightCursor, QTextDocument::FindCaseSensitively);
}
else{
highlightCursor = editCell->document()->find(foundText, highlightCursor);
}
}
}
highlightCursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
highlightCursor.mergeCharFormat(colorFormat);
}

}

//---------------------------------------------------------------------------

I want to add this line of code prior to exiting above routine: tableWidgetFindings->removeCellWidget (SearchRow.at(NextSearch), SearchColumn.at(NextSearch));
The reason is a savings in memory usage.

Now to my problem. I can not figure out a way to save the contents of "editCell" so that I can then place "editCell" content into
tableWidgetFindings->item(SearchRow.at(NextSearch), SearchColumn.at(NextSearch))... just before exiting above routine.
Every way that I have tried so far results in a loss of the "highlighted" text, not the actual text but the "highlighting".
Any help would be greatly appreciated.