Get data from every cell from a QTableView

后端 未结 1 1653
囚心锁ツ
囚心锁ツ 2020-12-10 08:48

I need the values from a QtableView, but I do not know how to do that without a signal emitted from the table.

The table takes its values from a txt-fi

相关标签:
1条回答
  • 2020-12-10 09:38

    The QTableView just displays the data contained in its model. You have to work with this model to retrieve the data. You must also define how you want to store the values. For instance:

    model = tableView.model()
    data = []
    for row in range(model.rowCount()):
      data.append([])
      for column in range(model.columnCount()):
        index = model.index(row, column)
        # We suppose data are strings
        data[row].append(str(model.data(index).toString()))
    
    0 讨论(0)
提交回复
热议问题