Caching the item's paint function

If you have items with a time-consuming paint function, you can change the item's cache mode. By default, no rendering is cached. With setCacheMode(), you can set the mode to either ItemCoordinateCache or DeviceCoordinateCache. The former renders the item in a cache of a given QSize element. The size of that cache can be controlled with the second argument of setCacheMode(), so the quality depends on how much space you assign. The cache is then used for every subsequent paint call. The cache is even used for applying transformations. If the quality deteriorates too much, just adjust the resolution by calling setCacheMode() again, but with a larger QSize element. DeviceCoordinateCache, on the other hand, does ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.