I have a simple QTableView (not QTableWidget) with multiple rows and columns. Users can click and select single cell in my QTableView. this is a part of my code:
def __init__(self, fileName, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
self.gui = form_class
self.model = QtGui.QStandardItemModel(self)
self.tableView.setModel(self.model)
self.tableView.resizeColumnsToContents()
self.tableView.clicked.connect(self.fn_get_cell_Value)
def fn_get_cell_Value(self):
model = self.tableView.model()
data = []
for cell in range(model.SelectedClicked):
data.append([])
value = str(model.data(index))
data[row].append(value)
How can I get this clicked cell value. Thanks
The slot must have a parameter where the QModelIndex of the model returns, in your case the code would look like this:
def fn_get_cell_Value(self, index):
datas = index.data()
print(datas)