Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QT android app slow scrolling
merlinko last edited by
I am trying to make a simple android app, but basically my problem is that on my main screen I have about 250 little images that i want to scroll. But I really need the scrolling to be fluent and fast. First I tried it using QML but it wasnt really fast, then I tried to make the app in qt designer and use widgets but that was very slow. Then I tried using openGL but on android I can only use openGL ES and I cant find so much examples because every example that I find is much more advanced than I need.
But basically my main question is, what do you think is the best way to solve my problem and if its openGL which way of using it is the best that could solve it?
Some general remarks:
- use lazy initialization - only load images when they are needed to be shown
- use MVP (ListView/ GridView etc.) - this will ensure the view only instantiates visible items (whatever is "scrolled away" is destroyed to free up resources)
- you can experiment with precaching the images, so that they are available in RAM, instead of reading them from SD card while scrolling
- do not use SVG images, they are slow to render
- optimize your images: scale them down, resize so that there is less data to load
- use a profiler to identify performance bottlenecks
I do recommend using QML for this, it should be able to handle the task. But that probably depends on the details of the task at hand. Maybe raw OpenGL could be a solution, but it would involve more work (and I can't help here because my OpenGL knowledge is minimal).
merlinko last edited by
I think I should add some more information. The images are not only images but they should be objects with some labels on them and user should be able to click them. I cannot use lazy initialization because it would be even slower. Today I tried MVP but only with the images as icons, but on android it was slow, on ios it was better. I use png images and their size is about 1kb and they are really scaled like icons.
I am really desperate now because i think there must be a proper solution for this. :/
Thanks for the answer btw :)
I cannot use lazy initialization because it would be even slower
How so? If you initially load 20 items instead of 250, it has to work faster. Unless you need to show all 250 at the same time (is this app displayed on some huge screen?).
I use png images and their size is about 1kb and they are really scaled like icons.
That does not sound like a vexing task for Qt or the CPU/ GPU at all, I've worked with Qt QML apps which show even ~160MB of image data and it was all smooth. I begin to suspect there is something else which makes it run slow for you. Are images loaded from network, by any chance? Maybe you could post some small code snippet of how you attempt to do it, or some wireframe of how the solution should look? Then I could try giving some more concrete hints on how to improve the performance.