从QTableView的每个单元格获取数据

我需要来自的值QtableView,但是我不知道如何在没有表发出信号的情况下进行操作。

该表从txt文件获取其值。从表中,我想使用值,但不使用表。该表只是一个缓冲区。那么,如何仅按aQPushButton即可从表中“获取”所有值,而又没有表本身发出任何信号?

回答:

QTableView仅显示其模型中包含的数据。您必须使用此模型来检索数据。您还必须定义如何存储值。例如:

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()))

以上是 从QTableView的每个单元格获取数据 的全部内容, 来源链接: utcz.com/qa/402255.html

回到顶部