[Development] How fast grab a QML item's content to image when it updates?

Shawn Rutledge Shawn.Rutledge at qt.io
Tue Dec 12 16:20:00 CET 2017

> On 12 Dec 2017, at 14:53, Denis Shienkov <denis.shienkov at gmail.com> wrote:
> > Did you try QQuickItem::grabToImage?
> Of course, it is veeery slowly.

If the frame was rendered on the GPU, you have to download it from there, and that is slower than if you had rendered into CPU memory, as widgets do by default.  Thus the note in the docs:

  Note: This function will render the item to an offscreen surface and copy 
  that surface from the GPU's memory into the CPU's memory, which can be 
  quite costly. For "live" preview, use layers or ShaderEffectSource.

So, maybe try to get the GPU to do whatever comes next after you think you need to grab the frame?  grabToImage is more for archival, not for real-time effects (although I did use it recently to record an animated GIF; I could only get 30FPS despite using a fairly powerful GPU, but that was good enough).

More information about the Development mailing list