//Add images as resources
for(int i = 0; i < vectorOfImages.size(); i++ )
{
QUrl url(QString("image_%1").arg(i));
textEdit->document()->addResource(QTextDocument::ImageResource, url, vectorOfImages.at(i));
}
//Process the htmlCode that is in QTextEdit.
int count = 0;
int pos = 0;
QRegExp rx("<img src=\".+/>");
while ((pos = rx.indexIn(htmlCode, pos)) != -1)
{
QString strToReplace(QString("<img src=\"image_%1\" />").arg(count));
htmlCode.replace(pos, rx.matchedLength(), strToReplace);
pos += rx.matchedLength();
count++;
}
textEdit->setText(htmlCode);