Is there a lightweight component I can use in a ScrollView?
-
At the moment, I'm using a ScrollView to display a customized QQuickPaintedItem. Unfortunately, my custom component can have a very large size so (based on some early experimenting) I think it is allocating a very large buffer for drawing. I would prefer that only a buffer large enough to fit the viewport is allocated and my drawing code is called to update just the visible portion instead of the entire component. However, I don't see a way to do this with this with a QQuickPaintedItem.
Is there some other component that will allow me to use a much smaller buffer and paint in a just-in-time fashion so that I can render a component with a large logical size?
-
At the moment, I'm using a ScrollView to display a customized QQuickPaintedItem. Unfortunately, my custom component can have a very large size so (based on some early experimenting) I think it is allocating a very large buffer for drawing. I would prefer that only a buffer large enough to fit the viewport is allocated and my drawing code is called to update just the visible portion instead of the entire component. However, I don't see a way to do this with this with a QQuickPaintedItem.
Is there some other component that will allow me to use a much smaller buffer and paint in a just-in-time fashion so that I can render a component with a large logical size?
@kitfox
https://doc.qt.io/qt-5/qquickpainteditem.html#textureSize-propalternatively(?) you can try to call
setRenderTarget(QQuickPaintedItem::FramebufferObject)
, since then no image texture is allocated? But i am not an expert on that matter -
I don't see a ready-made solution.
You could pass the ScrollView to the QQuickPaintedItem, or look for it by following the parentItem chain.
Use the underlying Flickable's contentX, contentY, etc, and QQuickItem::mapRectFromItem() to determine what portion of the QQuickPaintedItem is visible. Calls to update() will be necessary when the ScrollView's viewport changes, because the initial paint is expected to have painted the entire item into the backing store.