Qt World Summit: Register Today!

how do I load massive table views instantly?

  • say i have a few "playlists" that are really big, like 200k items, with many columns
    i'd like to be able to switch to them and have them be instantly loaded.

    by that i mean the entire list, such that i can take the scroll thumb and drag it to the bottom and see the last item, ie: no "loading by pages"

    alternately, if "loading only what you see" is just "how it's done", then can i just set the scroll bar height to be the total height? so the user CAN still grab the scroll thumb, and drag it to the end, and see the data at the end, without waiting for all the unseen data to load?

    i know other apps do this... how is it done?


  • Moderators

    Usually the heavy part is calculating the row heights, so if you're willing to set uniform row heights that should help.

  • If you would like to display/load only what is visible while its visible try this code, at beginning you can set up overall list size, but could allocate the rows only if they become visible.
    Buit it will make sorting not work correct until all loaded.

        QModelIndex firstVisible =  ui->list->indexAt(QPoint(0,0));
            int lastIndex;
            int firstIndex;
                 QModelIndex lastVisible =  ui->list->indexAt(QPoint(0,ui->list->size().height()));

  • sorting must work correctly, so that's not an option, right?

  • Lifetime Qt Champion

    Create your data structures in another thread and move them all into the model once ready. Or directly create a model in a separate switch and set this once it's filled up.

Log in to reply