Hey there,
I'm using a QTextDocument and QTextCursor::insertImage.
The goal is to remplace : - ) keywords by a in the text document.
ZePictureWidget * test = new ZePictureWidget("zeData/zeSmileys/Crying.png");
document
()->addResource
(QTextDocument::ImageResource,
QUrl("test"), test
->getPixmap
());
ZePictureWidget * test = new ZePictureWidget("zeData/zeSmileys/Crying.png");
document()->addResource(QTextDocument::ImageResource, QUrl("test"), test->getPixmap());
To copy to clipboard, switch view to plain text mode
//=============================================================================
//=============================================================================
void ZeSmileyController
::scanSmiley(QTextDocument & textDocument,
{
textCursor = textDocument.find(smiley);
while (textCursor.isNull() == false)
{
textCursor.deleteChar();
textCursor.insertImage("test");
textCursor = textDocument.find(smiley);
}
}
//=============================================================================
//=============================================================================
void ZeSmileyController::scanSmiley(QTextDocument & textDocument,
const QString & smiley,
const QString & path)
{
QTextCursor textCursor;
textCursor = textDocument.find(smiley);
while (textCursor.isNull() == false)
{
textCursor.deleteChar();
textCursor.insertImage("test");
textCursor = textDocument.find(smiley);
}
}
To copy to clipboard, switch view to plain text mode
Unfortunately when replacing 100 smileys it's very slow, it's like the Cursor is reloading the smileys over and over again.
Any idea?
Bookmarks