Hi everyone,
I'm trying to inherit QSqlTableModel to make data im my table display in way i need.
class TableViewModel(QSqlTableModel):
def __init__(self):
super(TableViewModel, self).__init__()
def flags(self, modelIndex):
if not modelIndex.isValid():
return
if modelIndex.column() != 1 and modelIndex.column() != 4:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
def data(self, modelIndex, role=Qt.DisplayRole):
if not modelIndex.isValid():
return QVariant()
if role != Qt.DisplayRole & role != Qt.EditRole:
return QVariant()
return record.value(modelIndex.column())
With this code i'm only getting empty cells. Without data() function this code work perfectly, the data displayed in TableView exactly it should be.
I'm just enmeshed by getting data from QSqlTableModel. Where can i find it? Or is it just my call wrong?
Thanks in advance,
serge