Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how do I load massive table views instantly?

how do I load massive table views instantly?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 320 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by davecotter
    #1

    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?

    -dave

    kshegunovK 1 Reply Last reply
    0
    • D davecotter

      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?

      -dave

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

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

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Q139
        wrote on last edited by Q139
        #3

        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));
            if(firstVisible.row()>=0){
        
                int lastIndex;
                int firstIndex;
        
                if(loadAll){
                     firstIndex=0;
                     lastIndex=ui->list->rowCount()-1;
                }else{
                    firstIndex=firstVisible.row();
                     QModelIndex lastVisible =  ui->list->indexAt(QPoint(0,ui->list->size().height()));
                    if(lastVisible.row()==-1){
                        lastIndex=ui->list->rowCount()-1;
                    }else{
                        lastIndex=lastVisible.row();
                    }
                }
        
        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved