你应该检查里面的情况
if role == Qt.BackgroundRole
def data(self, item, role): if role == Qt.BackgroundRole: if QSqlQueryModel.data(self, self.index(item.row(), 2), Qt.DisplayRole) == "Young": return QBrush(Qt.yellow) if role == Qt.DisplayRole: if item.column() == 3: return True if QSqlQueryModel.data(self, item, Qt.DisplayRole) == 1 else False return QSqlQueryModel.data(self, item, role)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)