Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Increase Performance of Text and Large String
Forum Updated to NodeBB v4.3 + New Features

Increase Performance of Text and Large String

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 2.1k 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.
  • K Offline
    K Offline
    kitizz
    wrote on last edited by
    #1

    Hullo, hopefully a quick question.

    I'm creating an interface for a serial terminal. The text for that terminal is often growing in length, especially when something this happening.

    As its size increases, it becomes increasingly slow to update. I'm sure it has everything to do with the fact that it's a few thousand pixels high and growing every 50ms.

    Is there a better way to handle the text in this situation?

    If it helps, I'm currently using TextArea{} for this.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      Are you updating whole text in your text area on new line?

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chrisadams
        wrote on last edited by
        #3

        Presumably it's laying out the entire text each time you update.
        To speed up text layouting, use the cheapest TextMode you can (PlainText preferably). It might be possible to disable kerning and hinting if you're using a monospaced font, I'm not sure. It's been a while since I delved into the text layout stuff, and to be honest, I hope to never see it again.

        Alternatively, split the text over multiple elements (perhaps newline delimited) - you could even use a stringlistmodel and a simple delegate for this. Just autoscroll to the most recently added delegate, and implement some data coalescing in your model to avoid delegate proliferation.

        Cheers,
        Chris.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kitizz
          wrote on last edited by
          #4

          Ah yeah, I like the multiple elements idea. I'll give it a test when I get back to that project. The main limitation of that method is not being able to select multiple lines to copy out (if needed).

          Thanks!

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tzander
            wrote on last edited by
            #5

            I suggest using the same text layout engine that Qt Creator uses, its optimized for huge amounts of text and only does layout of the stuff you see on screen.
            See the QPlainTextDocumentLayout class.
            Also see QTextEdit::document() and QTextDocument::setDocumentLayout().

            1 Reply Last reply
            0

            • Login

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