Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextBrowser::setPlainText and setSource calls take extremely long for large texts
Qt 6.11 is out! See what's new in the release blog

QTextBrowser::setPlainText and setSource calls take extremely long for large texts

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by Violet Giraffe
    #1

    QTextBrowser::setPlainText takes very long (about 1 minute for debug build) with a 14 MB ASCII text. Consumes 170-180 MB of memory, too (what for?!!). Once the text is loaded, the widget's performance is great - smooth scrolling etc., no problem. But such a long loading time makes it unusable. Is there anything I can do to speed it up?

    1 Reply Last reply
    1
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      The debug mode is always much slower then the release build. If you encounter this type of behavior, always check if the release mode is acceptable in terms of delays. Maybe the use of QTextEdit might speed things up?

      Greetz, Jeroen

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        No, it's faster in release but not by much. Still pretty much unusable.
        I think I used the QTextBrowser to enable HTML viewing, and I don't need an editor, just a viewer. Gonna try QTextEdit anyway, will be interesting to see if it's any faster.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by Jeroentjehome
          #4

          Why do you want to use the setPlainText function? Is the file not readable just as it is? The QTextBrowser supports setSource(). Maybe that will speed up the load?

          Greetz, Jeroen

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Violet Giraffe
            wrote on last edited by
            #5

            As I mentioned in the title, I've also tried setSource and there's no difference. Reading the file and loading it into QString is not the problem. Filling the QTextBrowser is.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by Violet Giraffe
              #6

              Turns out, QPlainTextEdit is fast while QTextEdit is slow. It has another problem, though: It takes ENORMOUS amount of time to free its internal memory blocks (QTextBlockData objects) when I clear the viewer.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved