16,212
社区成员
发帖
与我相关
我的任务
分享
QVariant UMemoryModel::data( const QModelIndex &index, int role /*= Qt::DisplayRole*/ ) const
{
if(role == Qt::ForegroundRole)
{
//判断index对应的行和列的数据是否大于5,大于则返回红色。
if(true/*数据大于5*/)
{
const QColor color = QColor::fromRgb(255,255,0);
QBrush brush(color);
return brush;
}
else
{
const QColor color = QColor::fromRgb(0,255,0);
QBrush brush(color);
return brush;
}
}
}