Nyaruko
Nyaruko

Reputation: 4459

Qt: too many setText calls cause lag

I am writing a central display widget, it contains many small cell widgets where each of them have some QLabels to display some text info.

I have about 100 QLabels in total. And each of them is updated in around 2 Hz. Then my GUI thread becomes very lag...

What is the possible solutions out there?

The 100 QLabels are in a scroll area btw.

Upvotes: 0

Views: 354

Answers (1)

vahancho
vahancho

Reputation: 21220

As you use a scroll area, I guess, you don't show all 100 labels at a time, right? Than you have to update only those labels that are visible. For that reason I would suggest using Qt Model-View-Controller (MVC) classes, such as QTableView, etc. That will ensure that only visible items (cells) will be processed, and performance wise this approach will be much efficient.

Upvotes: 2

Related Questions