PDA

View Full Version : QListView performance issue



zgulser
3rd June 2014, 16:31
Hi,

I have a tabbed application which one of them includes a QListView with custom item model & delegate. When application is minimized or maximized but one of the tabs which has no QListView in it is selected, CPU usage seems normal(about %6). But when I select a tab with a QListView, CPU usage rises to %30.

I seems like my QListView drains too much CPU. I knew that listview is rendering continuously via delegate's paint method and most probably that causes this extensive CPU usage. Or am I wrong?

I set my custom listview's setUniformItemSize to true but nothing changed.

Any ideas?

PS: I'm on Qt 4.8.

wysota
3rd June 2014, 16:34
Listview does not coninuously render via the delegate if you don't explicitly tell it to by constantly updating the view.

zgulser
3rd June 2014, 18:37
Ok then what could make it render continuously? Any suggestions for me to look at?

stampede
3rd June 2014, 23:51
Do you call "repaint()" manually anywhere in your code ?

d_stranz
4th June 2014, 02:19
Is your custom model emitting signals that would cause the list view to reload its contents when the tab is clicked? In particular, if beginInsertRows() / endInsertRows() is happening for every row in the model, this could do it. The list would have to repaint itself for every row.

zgulser
4th June 2014, 09:24
Do you call "repaint()" manually anywhere in your code ?

Thanks for the suggestion but I've already checked it.


In particular, if beginInsertRows() / endInsertRows() is happening for every row in the model, this could do it. The list would have to repaint itself for every row.

Yes actually I use them just before adding a new listitem to the list(as well as I use beginRemoveRows / endRemoveRows when removing a list item). But I thought I must sort of use them. Isn't it so?

wysota
4th June 2014, 09:29
Do you have a custom delegate? Can you show us its code?

zgulser
4th June 2014, 09:39
Ok guys I found my silly mistake. I was setting style sheet in paintEvent function. Sorry to waste your time. Thank you.