Good morning all,
does anyone know, how to color the QTableViews header by using the standard delegate in Qts MV architecture? I tried this by using the roles as it does in the data() method, but in the headerData() nothing happens :-(

Qt Code:
  1. QVariant SchulungsplanModel::headerData(int section, Qt::Orientation orientation, int role) const
  2. {
  3. // HORIZONTAL HEADER: (timeline)
  4. if (orientation == Qt::Horizontal)
  5. {
  6. if(role == Qt::BackgroundRole)
  7. return QVariant(QBrush(QColor(Qt::green), Qt::SolidPattern));
  8.  
  9. if(role == Qt::DisplayRole)
  10. {
  11. if (section < m_horizontalHeaderList.size())
  12. return m_horizontalHeaderList.at(section);
  13. }
  14. }
  15.  
  16. // VERTICAL HEADER: PUs
  17. if (orientation == Qt::Vertical)
  18. {
  19. if(role == Qt::DisplayRole)
  20. {
  21. if (section < m_verticalHeaderList.size())
  22. return m_verticalHeaderList.at(section);
  23. }
  24. }
  25.  
  26. return QAbstractTableModel::headerData(section, orientation, role);
  27. }
To copy to clipboard, switch view to plain text mode