Ok, I tried your suggestion..., but nothing is displayed in my table cells, do you know, what I am doing wrong ? How do I have to implement the sizeHint() function ?
void SchulungsplanDelegate
::paint(QPainter* painter,
const QStyleOptionViewItem
& option,
const QModelIndex &index
) {
painter->save();
if (option.
state & QStyle::State_Active) painter->fillRect(option.rect, option.palette.highlight());
// gets the cells size and draws the text inside
QRect myRect
= QRect(option.
rect.
topLeft(), option.
rect.
bottomRight()) ;
painter->drawText(myRect, Qt::AlignCenter, "test");
painter->restore();
}
/*
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
// ????????????
}
void SchulungsplanDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index)
{
painter->save();
if (option.state & QStyle::State_Active)
painter->fillRect(option.rect, option.palette.highlight());
// gets the cells size and draws the text inside
QRect myRect = QRect(option.rect.topLeft(), option.rect.bottomRight()) ;
painter->drawText(myRect, Qt::AlignCenter, "test");
painter->restore();
}
/*
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
// ????????????
}
To copy to clipboard, switch view to plain text mode
Bookmarks