Reputation: 189
I have tried QListWidget but it seems to display everything all at once instead of like a terminal would print each line individually in real time. I also tried the scrollToBottom() function with this and it still adds everything to the screen in one shot.I also tried to use a thread and the same thing happened.
I have a main window and a button to open a dialog. I want the scrolling text to be in the dialog(in a listview widget or whatever is needed).A constant stream of strings like "00 1A 2B 3C H6 77 66" being sent to the ui window (printed one after another) and see it scroll in real time. Scroll bars are hidden. The window is just for viewing data.
I'm not sure if QListView with the QAbstractItemList would work. I have been searching for the answer for days. None of the posts here seem to answer my question.
Does anyone know how I can achieve this effect? Thank you.
Upvotes: 1
Views: 538
Reputation: 126867
Appending text to a QPlainTextEdit
whenever it's generated and calling its scrollToBottom
method will produce the usual "log"/terminal effect just fine; same for list controls.
If do this but see all the text just appear together at the end of the operation, are you sure you aren't blocking the UI thread, so the UI gets a chance to repaint only at the end of your lengthy operation?
If that is the case, you should move your long operation to a separate thread, and deliver the log lines to the UI thread using e.g. queued connections (you cannot access directly widgets from any thread other than the one where the QApplication
lives).
Upvotes: 1