Nominate our 2022 Qt Champions!

Edit QStandardItem text remote when using proxyfiltermodel to filter data

  • Hi, I can't figure out how to change the text in my QTableView from code when I'm using a proxy filter.
    Any help is appreciated

    I am using a QTableView to hold a large amount of data within a QStandardItemModel.
    I'm using a combobox to let the user filter the data to manageable size and a QProxyFilterModel to do the actual filtering.
    Now when I want to change the filtered data with code, I don't understand how to get the say first filtered row and third column item to set new data to.

  • By pure chance did I find this, and after my modification, and it seems to work
    ui->tblView->model()->setData(ui->tblView->model()->index(1,4,QModelIndex()), QString("Testar"), Qt::EditRole);

    So if I got this right, since I set my QTableView Model to the proxymodel and filter with. The above tblView->model() returns the result from the filter as a model....
    Also, using ->setData let min change the data as long as I'm using the QStandardItem in my model plus using Qt::EditRole.

Log in to reply