[self Solved]model segmentation fault



  • 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);
    }
    

    }

    @



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.