[Qt-interest] qwidget performance

Tomasz Grobelny tomasz at grobelny.oswiecenia.net
Wed Jun 15 11:53:35 CEST 2011


On Wed, 15 Jun 2011 06:56:37 +0200, Andre Somers <andre at familiesomers.nl>
wrote:
> 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?
> 
Actually I doubt I will ever need 100000 widgets but considering they
might be more complicated than QPushButton I just wanted to test
performance.
As for the design: this is not a random collection of 100000 elements but
it is organized by person and date (so it is easy enough to find the right
one). For each person we may need 100 items and loading 10's of crew
members is commonly done. What if the client decided he needs 200 crew
members? Or loads 2000 by accident?

> 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.
> 
You are probably right that not all QWidgets should be instantiated at any
given time. I also got an off-list reply that I could have a look at item
delegates (which looks promising). Any other ideas on how to reuse
on-screen widgets are welcome.
-- 
Regards,
Tomasz Grobelny



More information about the Qt-interest-old mailing list