I'm using the QTableView
class with this model:
class PaletteTableModel(QtCore.QAbstractTableModel):
def __init__(self,colors = [[]],headers =[],parent=None):
QtCore.QAbstractTableModel.__init__(self, parent)
self.__colors=colors
self._headers=headers
def rowCount(self,parent):
return len(self.__colors)
def columnCount(self,parent):
return 6
def headerData(self,section,orientation,role):
if role==QtCore.Qt.DisplayRole:
if orientation==QtCore.Qt.Horizontal:
return self._headers[section]
else:
return QtCore.QString("Credit %1").arg(section+1)
def data(self,index,role):
if role==QtCore.Qt.ToolTipRole:
row=index.row
return "Crédit"
if role==QtCore.Qt.EditRole:
row=index.row()
column=index.column()
return self.__colors[row][column]
if role==QtCore.Qt.DisplayRole:
row=index.row()
column=index.column()
value=self.__colors[row][column]
return value
def setData(self,index,value,role=QtCore.Qt.EditRole):
if role==QtCore.Qt.EditRole:
row =index.row()
column=index.column()
ch=(value)
self.__colors[row][column]=ch
self.dataChanged.emit(index,index)
return True
def flags(self, index):
return QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsSelectable
I want to retrieve the selected row of this table-view. (And I want to have Python code, if possible).