How to change delegate's sizeHint on TableView's cell focus?
-
Hey there!
I've got some troubles with custom delegate's sizeHint:
I want to "unfold" cell (row with this cell) on it's focus; otherwise return default size;
QTableVew connected to resize rows on mouse press:
@
connect(m_scheduleView, &QTableView::pressed, m_scheduleView, &QTableView::resizeRowsToContents);
@
@
QSize DBScheduleItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.state & QStyle::State_HasFocus) {
... // this block never executes;
return // some calculated size;
}
return QSize(width, height); // default size;
}
@
Code in conditional block has never executed, but the same condition on delegate's paint() executes properly:
@
void DBScheduleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.state & QStyle::State_HasFocus)
painter->fillRect(...);
}
@
So, how to catch cell focus in sizeHint?