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. Fill QTableWidget
Forum Updated to NodeBB v4.3 + New Features

Fill QTableWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 393 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.
  • M Offline
    M Offline
    marango27
    wrote on last edited by
    #1

    Hello everyone, I hope you are well.
    I have been working with QT for about 1 year, now I have a new challenge where I have to display information.
    I am using a QTableView for this, what happens is that when the table is filled, the software freezes and after it finishes filling it unfreezes. Can someone please indicate what is happening, thank you.

    jsulmJ 1 Reply Last reply
    0
    • M marango27

      Hello everyone, I hope you are well.
      I have been working with QT for about 1 year, now I have a new challenge where I have to display information.
      I am using a QTableView for this, what happens is that when the table is filled, the software freezes and after it finishes filling it unfreezes. Can someone please indicate what is happening, thank you.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @marango27 said in Fill QTableWidget:

      Can someone please indicate what is happening, thank you.

      Well, I guess you block the event loop with your long lasting operation. You need to provide more information if you want to get meaningful help.

      • How many entries do you insert into the table?
      • Are you doing any heavy calculations when filling the table?
      • Can you show your code?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      3
      • jsulmJ jsulm

        @marango27 said in Fill QTableWidget:

        Can someone please indicate what is happening, thank you.

        Well, I guess you block the event loop with your long lasting operation. You need to provide more information if you want to get meaningful help.

        • How many entries do you insert into the table?
        • Are you doing any heavy calculations when filling the table?
        • Can you show your code?
        M Offline
        M Offline
        marango27
        wrote on last edited by
        #3

        @jsulm thanks for you attention.
        the entries are more or less than 2000 or 5000 rows. So right at the moment it starts inserting into the table it locks the entire interface and tries to crash the software

        Let's pretend that the arrangement I am going through has 2000 to 5000 entries, but even if they are less, it blocks and tries to fail. I've thought of using a helper class with a thread and pausing milliseconds for each input

        model_old = new QStandardItemModel(min, 14, this);
            //ui->table_old_db->setColumnCount(14);
            QStringList headers;
            //Sets headers in tables
            headers << "RES-1" << "CAP-1" << "RES-2"  << "CAP-2" << "RES-3" << "CAP-3" << "RES-4"<< "CAP-4"<< "RES-5"<< "CAP-5"<< "RES-6"<< "CAP-6"<< "TEMP-RAW"<< "TEMP-ENG";
            model_old->setHorizontalHeaderLabels(headers);
        
            ui->table_old_db->setModel(model_old);
            int fila=0;
            //creo las posiciones necesarias para las compensaciones para que asi no se salgo por error
            fill_all();
        
            for (int j=0;j<min;j++){
                for(int col = 0; col < 14; col++){
                    QModelIndex index = model_old->index(j,col,QModelIndex());
                    // 0 for all data
                    if((col % 2) == 0){
                        //resistivos
                        model_old->setData(index, QString::number(database->get_data_all_nodes_old()[fila][j].get_raw_resis()));
                    }else{
                        model_old->setData(index, QString::number(database->get_data_all_nodes_old()[fila][j].get_eng_capa()));
                        fila++;
                        if(fila > 6){
                            fila=0;
                        }
                    }
        
                    if(col == 12){
                        model_old->setData(index, QString::number(database->get_data_all_nodes_old()[6][j].get_raw_tempe()));
                    }else if(col == 13){
                        model_old->setData(index, QString::number(database->get_data_all_nodes_old()[6][j].get_eng_tempe()));
                    }
                }
            }
        
        JonBJ 1 Reply Last reply
        0
        • M marango27

          @jsulm thanks for you attention.
          the entries are more or less than 2000 or 5000 rows. So right at the moment it starts inserting into the table it locks the entire interface and tries to crash the software

          Let's pretend that the arrangement I am going through has 2000 to 5000 entries, but even if they are less, it blocks and tries to fail. I've thought of using a helper class with a thread and pausing milliseconds for each input

          model_old = new QStandardItemModel(min, 14, this);
              //ui->table_old_db->setColumnCount(14);
              QStringList headers;
              //Sets headers in tables
              headers << "RES-1" << "CAP-1" << "RES-2"  << "CAP-2" << "RES-3" << "CAP-3" << "RES-4"<< "CAP-4"<< "RES-5"<< "CAP-5"<< "RES-6"<< "CAP-6"<< "TEMP-RAW"<< "TEMP-ENG";
              model_old->setHorizontalHeaderLabels(headers);
          
              ui->table_old_db->setModel(model_old);
              int fila=0;
              //creo las posiciones necesarias para las compensaciones para que asi no se salgo por error
              fill_all();
          
              for (int j=0;j<min;j++){
                  for(int col = 0; col < 14; col++){
                      QModelIndex index = model_old->index(j,col,QModelIndex());
                      // 0 for all data
                      if((col % 2) == 0){
                          //resistivos
                          model_old->setData(index, QString::number(database->get_data_all_nodes_old()[fila][j].get_raw_resis()));
                      }else{
                          model_old->setData(index, QString::number(database->get_data_all_nodes_old()[fila][j].get_eng_capa()));
                          fila++;
                          if(fila > 6){
                              fila=0;
                          }
                      }
          
                      if(col == 12){
                          model_old->setData(index, QString::number(database->get_data_all_nodes_old()[6][j].get_raw_tempe()));
                      }else if(col == 13){
                          model_old->setData(index, QString::number(database->get_data_all_nodes_old()[6][j].get_eng_tempe()));
                      }
                  }
              }
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @marango27
          How can we answer this? How expensive is database->get_data_all_nodes_old() or get_raw_resis() etc.? We don't know whether that takes a nanosecond or a minute? If database->get_data_all_nodes_old() is expensive, why not pre-calculate that outside the loop since it's constant? When do you execute this code? Since you are creating a brand new model and attaching a table view each time, why don't you first fill the model with all the data and only do the ui->table_old_db->setModel(model_old); at the end, in case that is taking time to update with all the data changed signals flying around? How long does the model filling take, excluding any table view?

          1 Reply Last reply
          2

          • Login

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