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. How to have a live text feed that updates
Forum Updated to NodeBB v4.3 + New Features

How to have a live text feed that updates

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 358 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.
  • R Offline
    R Offline
    RangerACR
    wrote on last edited by
    #1

    So im working on a project that handles comparing 3 databases. What I am trying to do is have some kind of view where as the app is comparing items in the databases it just gives details as to where its at and what's matching/not matching.

    Ex. If its connecting to a database then it would append "Opening connection" ,if it found a match it would append to the view "Match for <item> was found" or "Match was not found for <item>".

    I have tried QTextEdit.append() , a fast append work around for qtextedit , QPlainTextEdit append/insert, and qlistwidget additem.
    All 3 seem to be unable to keep up with the app. I placed a qDebug() inside the comparison loop to see the time difference from the time ALL comparisons are completed and the ui updating, and its almost 6-7s. (the debug would print 3001 matches before a single line appeared on either 3 views).

    So is there a view that I can append/insert a string and update near the same speed as the qDebug() statements able to print?

    M JonBJ 2 Replies Last reply
    0
    • R RangerACR

      So im working on a project that handles comparing 3 databases. What I am trying to do is have some kind of view where as the app is comparing items in the databases it just gives details as to where its at and what's matching/not matching.

      Ex. If its connecting to a database then it would append "Opening connection" ,if it found a match it would append to the view "Match for <item> was found" or "Match was not found for <item>".

      I have tried QTextEdit.append() , a fast append work around for qtextedit , QPlainTextEdit append/insert, and qlistwidget additem.
      All 3 seem to be unable to keep up with the app. I placed a qDebug() inside the comparison loop to see the time difference from the time ALL comparisons are completed and the ui updating, and its almost 6-7s. (the debug would print 3001 matches before a single line appeared on either 3 views).

      So is there a view that I can append/insert a string and update near the same speed as the qDebug() statements able to print?

      M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      @RangerACR
      If you don't mine freezing the ui during the process, call QTextEdit.repaint() after each append().

      Otherwise you should have to use a separate thread for the comparaison process and send signals to the main thread to update the text edit.

      A third solution is to use a timer doing a single comparaison at a time. Not the easiest way sometimes but should be possible with database queries.

      1 Reply Last reply
      2
      • R RangerACR

        So im working on a project that handles comparing 3 databases. What I am trying to do is have some kind of view where as the app is comparing items in the databases it just gives details as to where its at and what's matching/not matching.

        Ex. If its connecting to a database then it would append "Opening connection" ,if it found a match it would append to the view "Match for <item> was found" or "Match was not found for <item>".

        I have tried QTextEdit.append() , a fast append work around for qtextedit , QPlainTextEdit append/insert, and qlistwidget additem.
        All 3 seem to be unable to keep up with the app. I placed a qDebug() inside the comparison loop to see the time difference from the time ALL comparisons are completed and the ui updating, and its almost 6-7s. (the debug would print 3001 matches before a single line appeared on either 3 views).

        So is there a view that I can append/insert a string and update near the same speed as the qDebug() statements able to print?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @RangerACR
        Everything @mpergand has said.

        I would have expected QPlainTextEdit to be the best choice available. FWIW assign it a fixed-width font. Do you append one line at a time? Consider appending batches of lines with \n between lines as necessary.

        It just won't be as fast as a "console" window. Mind, your use cannot keep up with all this information, consider reducing it. Otherwise you'll have to look into possibilities like using an actual console window.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RangerACR
          wrote on last edited by
          #4

          @JonB I tried both. I tried to figure out a way to do it line by line (I think the issue is your appending faster than the ui can update so its freezing up, I think I read somewhere where this is the case).
          I also tried just making a string and appending the lines to it and either doing it in batches of 100,1k lines and then finally tried just saying oh well and doing all of it in one append but its almost same runtime on ui displaying.

          Note: QPlainTextEdit did seem slightly less delayed when i did insert but it is well after the comparisons are done.

          @mpergand I will look into threads, I was thinking this was probably going to be the way to do it. Unfort, im pretty knew to threading so Ill have to look over it and try to implement it over the weekend.

          Ill update how the threading vs. repaint works compared to the other methods ive tried. Like I said its not like the 5-6s of freeze is a big deal, I was just curious of other methods.

          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