Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change delegate's sizeHint on TableView's cell focus?

How to change delegate's sizeHint on TableView's cell focus?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 901 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    savva.surenkov
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved