How to improve my qml app performance? ( QQuickPaintedItem )
-
Hi,
I have main qml page, where I have 10 buttons. When user click one of them, qml loads different pages ( I useLoader
andloader.source
). One of this page is very heavy ( in this page I have QQuickPaintedItem, which do heavy calculations ). Everytime, when user click on Button1, user has to wait. Is it possible to create that page only once and keep it on variable or in memory?main.qml:
Loader { id: loader } Button1 { onClicked { loader.source = page1.qml; } }
-
Hi,
I have main qml page, where I have 10 buttons. When user click one of them, qml loads different pages ( I useLoader
andloader.source
). One of this page is very heavy ( in this page I have QQuickPaintedItem, which do heavy calculations ). Everytime, when user click on Button1, user has to wait. Is it possible to create that page only once and keep it on variable or in memory?main.qml:
Loader { id: loader } Button1 { onClicked { loader.source = page1.qml; } }
@TomNow99 There are a few solutions which you can use, or combine them for biggest effect:
- keep your heavy page in a separate loader and only hide it (
visible = false
) when user navigates away from it. This is probably the easiest solution to do - in your painted item, cache the results: render your item into a QImage (or something else) and keep that image stored somewhere. Then when user navigates back to heavy page, show the image instead of rendering the whole item from scratch
- keep your heavy page in a separate loader and only hide it (