QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role ==Qt::BackgroundRole)
{
//if(orientation == Qt::Vertical)
if (orientation == Qt::Horizontal)
switch (section)
{
case 0:
return QBrush(QColor(Qt::blue));
case 1:
return QVariant(QColor(Qt::blue));
default:
return QAbstractTableModel::headerData(section,orientation,role);
}
可以设置headerData的字体颜色,字体加粗。data的字体颜色,背景色,字体风格等。
但是就是不能设置headerData的背景色。
setStyleSheet设置背景色可以起作用,但是我要根据用户的操作动态的来设置其中的某几个个列或者几个行的表头背景色。
这个问题在CSDN发帖了,但是解决不了所以又跑到这里来问了,希望大家help一下。
3Q
↧