Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2008
QTextDocument slow imagei insert


Message 1 in thread

Hey there,

I'm using a QTextDocument and QTextCursor::insertImage.
The goal is to remplace : - ) keywords by a in the text document.

Qt Code:

      ZePictureWidget * test = new 
ZePictureWidget("zeData/zeSmileys/Crying.png");
      document()->addResource(QTextDocument::ImageResource, QUrl("test"), 
test->getPixmap());

Qt Code:

      //=============================================================================
      //=============================================================================
      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);
          }
      }

Unfortunately when replacing 100 smileys it's very slow, it's like the 
Cursor is reloading the smileys over and over again.

Any idea?

--
 [ signature omitted ]