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. [self Solved]model segmentation fault
Forum Updated to NodeBB v4.3 + New Features

[self Solved]model segmentation fault

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.9k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pmjz
    wrote on last edited by
    #1

    I have generated a list that holds 1000 list for user info, every time I just get 40 users and display in the QTableView. that means, 0-39, when users scroll to 40, the application will get other 40 users and display. so,my solution works very well when I scroll down, for example 0-39 and then 40 - 79. but if I wanna go back, 40 -> 39, as soon as I click the vertical bar, the application inform me "model->insertRow(row,iterator.next)" segmentation fault. welcome any ideas.

    @
    void TestHugeDataDialog::updateTableModel(const QList< QList<QStandardItem*> > &list,int value)
    {
    QStandardItemModel *model;
    bool setModelFlag = false;
    if(!ui->tableView->model()){
    model = new QStandardItemModel(this);
    setModelFlag = true;
    }else{
    model = qobject_cast<QStandardItemModel >(ui->tableView->model());
    }
    model->clear();
    QListIterator< QList<QStandardItem
    > > iterator(list);
    int row = 0;

    while(iterator.hasNext())
    {
        model->insertRow(row,iterator.next());
        row++;
    }
    
    
    model->setHeaderData(0,Qt::Horizontal,tr("Name"));
    model->setHeaderData(1,Qt::Horizontal,tr("Address"));
    if(setModelFlag){
        ui->tableView->setModel(model);
    }
    

    }

    @

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pmjz
      wrote on last edited by
      #2

      this sinppet is not wrong, I just delete data that has been new. big lesson

      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