[Qt-interest] qwidget performance

Andre Somers andre at familiesomers.nl
Wed Jun 15 06:56:37 CEST 2011


Op 14-6-2011 23:43, Tomasz Grobelny schreef:
> I was doing a test where I create a lot of widgets (I used QPushButtons as an
> example) in one window (inside QScrollArea; only tiny portion of the created
> widgets are visible at any given time). As long as there are under 10000
> widgets the creation time is acceptable but then is starts to grow quite
> quickly. Creating 1000000 widgets is virtually impossible. Is there any way to
> improve performance in this case (except from dropping qwidgets in favor of
> drawing rectangles manually).
Well... re-thinking your design would be one obvious way to improve 
performance. Do you really expect a user to sort through 10k, let alone 
100k widgets in one huge scroll view and interact with the right one? 
That's not what I call a very user friendly design. Seriously: why do 
you really need to do this?

A technical way to deal with what you want, would be to simply not 
create them at all. Why do you need to create widget 90000, if your 
scroll area displays only widgets 0 to 10? You'll need to be a bit 
smarter about what you display and what not. What's more, even then you 
probably want to recycle widgets instead of deleting and then 
re-creating them, which means that you'll be effectively re-creating an 
item view manually. You could perhaps leverage QML's list view for this, 
in combination with the (still in progress) Component elements.

André






More information about the Qt-interest-old mailing list