Originally Posted by
wirasto
And your sample, the same as that in there. But unfortunately code like that do not display data.
That's because it is only a part out of the whole function. You have to respect the other roles by yourself or - as below - call the base class.
Originally Posted by
wirasto
def data(self, index, role):
if role == Qt.TextAlignmentRole:
if (index.column()==2):
return value
def data(self, index, role):
value=QSqlQueryModel.data(self, index, role)
if role == Qt.TextAlignmentRole:
if (index.column()==2):
return QVariant(Qt.AlignRight)
return value
To copy to clipboard, switch view to plain text mode
For speed and performance issues you should better use:
def data(self, index, role):
if role == Qt.TextAlignmentRole:
if (index.column()==2):
return QVariant(Qt.AlignRight)
return QSqlQueryModel.data(self, index, role)
def data(self, index, role):
if role == Qt.TextAlignmentRole:
if (index.column()==2):
return QVariant(Qt.AlignRight)
return QSqlQueryModel.data(self, index, role)
To copy to clipboard, switch view to plain text mode
Bookmarks