How to have a live text feed that updates
-
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?
-
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?
@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.
-
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?
@RangerACR
Everything @mpergand has said.I would have expected
QPlainTextEditto 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\nbetween 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.
-
@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.