I think, i will have to devide the cell into two or more rectangles and paint into the devided new rectangles, perhaps like this:

Qt Code:
  1. void SchulungsplanDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index) const
  2. {
  3. if (index.column() == 3 && index.row() == 2)
  4. {
  5. painter->save();
  6.  
  7. if (option.state & QStyle::State_Active)
  8. painter->fillRect(option.rect, QBrush(QColor(Qt::darkGreen), Qt::SolidPattern));
  9. if (option.state & QStyle::State_Selected)
  10. painter->fillRect(option.rect, QBrush(QColor(Qt::red), Qt::SolidPattern));
  11.  
  12. QRect rect1 = QRect(option.rect->topLeft(),
  13. QPoint(option.rect->center()->x(), option.rect->bottomLeft()->y()));
  14.  
  15. QRect rect2 = QRect(QPoint(option.rect->center()->x(), option.rect->topRight->y()),
  16. option.rect->bottomRight());
  17.  
  18. painter->setPen(QColor(Qt::white));
  19. painter->drawText(rect1, Qt::AlignCenter, " RECT1 ");
  20. painter->setPen(QColor(Qt::yellow));
  21. painter->drawText(rect2, Qt::AlignCenter, " RECT2 ");
  22.  
  23. /*
  24. QPoint iconStart = ... end of text
  25. QPoint iconEnd = ... end of cell ???
  26. QRect iconsRect = ...
  27. painter->drawPixmap(iconsRect, QPixmap("test.png"));
  28. */
  29.  
  30. painter->restore();
  31. }
To copy to clipboard, switch view to plain text mode