Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-271

Make QTextDocument::setHtml() faster

    XMLWordPrintable

Details

    Description

      It would be nice if QTextDocument::setHtml() was faster.

      For large html documents the function takes a long time to complete.
      Consider the following example,
      These are the times it takes for the setHtml() to complete when the for-loop has run to make a html string:
      500 times -> 2 seconds
      1000 times -> 5 seconds
      2000 time -> 23 seconds
      9000 times -> 497 seconds

      #include <QtGui>
      #include <QDebug>
      #include <QTime>

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

      QString html = "";
      for (int a=0; a < 1000; a++)

      { html += "<TABLE BORDER=1> <CAPTION>A test table with merged cells</CAPTION> <TR><TH ROWSPAN=2><TH COLSPAN=2>Average <TH ROWSPAN=2>other<BR>category<TH>Misc <TR><TH>height<TH>weight<TR><TH ALIGN=LEFT>males<TD>1.9<TD>0.003 <TR><TH ALIGN=LEFT ROWSPAN=2>females<TD>1.7<TD>0.00</TABLE>"; }

      QTime time;
      QTextEdit tedit;
      tedit.show();
      time.start();
      tedit.setHtml(html);
      qDebug() << time.elapsed();

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes