void SchulungsplanDelegate
::paint(QPainter* painter,
const QStyleOptionViewItem
& option,
const QModelIndex &index
) const {
if (index.column() == 3 && index.row() == 2)
{
painter->save();
if (option.
state & QStyle::State_Active) painter
->fillRect
(option.
rect,
QBrush(QColor(Qt
::darkGreen), Qt
::SolidPattern));
if (option.
state & QStyle::State_Selected) painter
->fillRect
(option.
rect,
QBrush(QColor(Qt
::red), Qt
::SolidPattern));
QPoint(option.
rect->center
()->x
(), option.
rect->bottomLeft
()->y
()));
QRect rect2
= QRect(QPoint(option.
rect->center
()->x
(), option.
rect->topRight
->y
()),
option.rect->bottomRight());
painter
->setPen
(QColor(Qt
::white));
painter->drawText(rect1, Qt::AlignCenter, " RECT1 ");
painter
->setPen
(QColor(Qt
::yellow));
painter->drawText(rect2, Qt::AlignCenter, " RECT2 ");
/*
QPoint iconStart = ... end of text
QPoint iconEnd = ... end of cell ???
QRect iconsRect = ...
painter->drawPixmap(iconsRect, QPixmap("test.png"));
*/
painter->restore();
}
void SchulungsplanDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index) const
{
if (index.column() == 3 && index.row() == 2)
{
painter->save();
if (option.state & QStyle::State_Active)
painter->fillRect(option.rect, QBrush(QColor(Qt::darkGreen), Qt::SolidPattern));
if (option.state & QStyle::State_Selected)
painter->fillRect(option.rect, QBrush(QColor(Qt::red), Qt::SolidPattern));
QRect rect1 = QRect(option.rect->topLeft(),
QPoint(option.rect->center()->x(), option.rect->bottomLeft()->y()));
QRect rect2 = QRect(QPoint(option.rect->center()->x(), option.rect->topRight->y()),
option.rect->bottomRight());
painter->setPen(QColor(Qt::white));
painter->drawText(rect1, Qt::AlignCenter, " RECT1 ");
painter->setPen(QColor(Qt::yellow));
painter->drawText(rect2, Qt::AlignCenter, " RECT2 ");
/*
QPoint iconStart = ... end of text
QPoint iconEnd = ... end of cell ???
QRect iconsRect = ...
painter->drawPixmap(iconsRect, QPixmap("test.png"));
*/
painter->restore();
}
To copy to clipboard, switch view to plain text mode
Bookmarks