November 17, 2011

Asperamanca Asperamanca
Hobby Entomologist
379 posts

Caching QIcon

 

I would like to write a simple cache for QIcons. To do that, I need to get some approximation of how much memory an icon reserves.

Any idea how I could find that out?

4 replies

November 17, 2011

BilbonSacquet BilbonSacquet
Lab Rat
75 posts

It’s depending of the size and the number of pixmaps you are using to construct this icon.

And if you call pixmap() function you get only a ‘just in time’ pixmap construct from the pixmap you have set.

Probably the easiest way to create your cache, implement your inherited icon engine from QIconEngineV2() … and trace what’s coming from addPixmap().

November 17, 2011

Asperamanca Asperamanca
Hobby Entomologist
379 posts

Okay, I found a simpler approach:
Instead of caching the QIcon, I simply cache all the pixmaps that go into it. Since I am the one constructing the icons, that’s pretty easy, and has the added benefit that pixmaps used both in icons and elsewhere are caches only once.

November 17, 2011

Volker Volker
Robot Herder
5428 posts

In that case: have a look at QPixmapCache then, it should have everything you need.

November 17, 2011

Asperamanca Asperamanca
Hobby Entomologist
379 posts

Yes, it does!

Thanks, all!

 
  ‹‹ [Solved]Opening a New Form with new Widgets.      Another "change qt application language at runtime" thread. ››

You must log in to post a reply. Not a member yet? Register here!