QListWidget flickering


currently I have a QListWidget that I fill with items. This items are log lines from software. But QListWidget flickers like hell if many data arrives. Sometimes it leave blank sometimes it show something. Any idea how to optimize this?

Ingo FoersterProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trinitrotolueneDirector - Software EngineeringCommented:
why don't you have a caching strategy rather than load in real time? pre-fetch and then display as opposed to doing both at the same time.

Else create a separate thread for the load and let your GUI run in a separate thread. Fire an event when the data load completes and then let your GUI thread pick up the updates....
if you were using addItem or insertItem function to fill QListWidget you may change to 'addItems' resp. 'insertItems'. flickering occurs if the whole list was painted for each update. this is often due to event handling which forces additional paintings by invalidating parts of the window. or by customizing the list for example by drawing images or additional lines.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ingo FoersterProgrammerAuthor Commented:
@ trinitrotoluene
I always use an own thread to decouple. This cause the flickering. If I do not use the own thread the UI is freeze until the list filling is finished.
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Ingo FoersterProgrammerAuthor Commented:
I will try your suggestion.
I always use an own thread to decouple. This cause the flickering.
the thread my not cause painting. instead it should fill a shared list (container) with the data and then send a message to the main thread that it should refill from list.

if the thread is the only one which writes to the list, you not even need a mutex. simply write to the container and signal end of writing by a message to the gui and end the thread. then the main thread may take responsibility.

Ingo FoersterProgrammerAuthor Commented:
I use now the function to add more than one item at the same time and it works better. Thanks for the hint.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.