Can't you just cache the rendered output and just paint the cached image in the paint event?
Can't you just cache the rendered output and just paint the cached image in the paint event?
I don't think so... I have hundreds of images being generated on the fly every second. I put them in a QGraphicsScene with a bunch of other QGraphicsItems. The user has the ability to make some of the QGraphicsItems visible/invisible at run time, so at the time the images are generated, I don't know which will be needed and which won't be needed.
Once an image does get rendered, I cache the rendered image for any repaintings. But the normal use case is to generate new images at 60fps. I do have time to render just the "top layer" of images and keep that frame rate. But because I am also spending time rendering in paint() calls for the lower (obscured) images, I'm overrunning my frame time.
60fps? and than hundreds of images at this rate? Then you should definitely think about your design. E.g. render the stuff in separate threads. But why such a high frame rate at all?
Did you take a look at https://doc.qt.io/qt-5/qgraphicsitem...CacheMode-enum ?
I'd like to avoid the call to paint() in the first place, so caching doesn't help. The high frame rate is because my application takes input from a connected camera which outputs at that rate. I turn its output into processed video.
Added after 8 minutes:
Thanks for the suggestions though. I'll think about some other ways I can avoid putting the QGraphicsItems in the scene in the first place
Last edited by Micah; 5th June 2019 at 22:07.
You should probably consider using a different display technology, e.g. QtQuick, which is rendered hardware accelerated on the GPU.
Cheers,
_
Bookmarks