[Interest] ListView/ListModel optimization

Shantanu Tushar shaan7in at gmail.com
Mon May 9 08:22:22 CEST 2016


You might want to profile where exactly things are slowing down (infact
your console.log calls should help as well). If its the model that is
taking too much time to populate, you should use a C++ model.

On Tue, May 3, 2016 at 11:02 PM, Kevin Mcintyre <kebin70 at gmail.com> wrote:

> Given code like below where JSON data is used to populate a ListModel - I run into loading issues on mobile when the number of objects returned is greater than a couple thousand.s
>
>
> Once the item is rendered it performs as expected, but the time to ready is often beyond user acceptance.
>
>
> Any suggestions greatly appreciated.
>
>  import QtQuick 2.5
>
> import QtQuick.Window 2.2
>
>
> Window {
>
>     visible: true
>
>
>     Repeater {
>
>         model: ['url1','url2','url3']
>
>         ListView {
>
>             delegate: Image {
>
>                 source: src
>
>             }
>
>             model: ListModel {
>
>                 Component.onCompleted {
>
>                     var xhr = new XMLHttpRequest();
>
>                     xhr.onreadystatechange = (function(data) {
>
>                         return function() {
>
>                             if ( data.readyState == 4 ) {
>
>                                 console.log('answered:', url)
>
>                                 try {
>
>                                     var js = eval('new Object(' + data.responseText + ')')
>
>                                     for (var x = 0; x < js.length;x++) {
>
>                                         append({'src': js[x].src})
>
>                                     }
>
>                                 } catch (err) {
>
>                                     console.log('error:', modelData, err);
>
>                                 }
>
>                             }
>
>                         }
>
>                     })(xhr);
>
>                     console.log('request:', url)
>
>                     xhr.open('GET', modelData, true);
>
>                     xhr.setRequestHeader('accept','application/json')
>
>                     xhr.send('');
>
>                 }
>
>             }
>
>         }
>
>     }
>
> }
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>


-- 
Shantanu Tushar    (UTC +0530)
shantanu.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160509/505cd16f/attachment.html>


More information about the Interest mailing list