Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Caching QIcon
Forum Updated to NodeBB v4.3 + New Features

Caching QIcon

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • BilbonSacquetB Offline
      BilbonSacquetB Offline
      BilbonSacquet
      wrote on last edited by
      #2

      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().

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

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

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #5

            Yes, it does!

            Thanks, all!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved