Hello, I am trying to implement an item delegate for a list view which should display additional information for any selected item. In order to display this additional information, I would need to allocate more space on screen to the selected item. For this, I tried to implement sizeHint() of the item delegate in the following way:

Qt Code:
  1. QSize MyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
  2. {
  3. const bool sel(option.state.testFlag(QStyle::State_Selected));
  4.  
  5. QSize size1;
  6. QSize size2;
  7.  
  8. /* compute size1 and size2... */
  9.  
  10. if (sel)
  11. {
  12. return size1;
  13. }
  14. else
  15. {
  16. return size2;
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

However, flag State_Selected does not seem to be set when the size hint is requested from the delegate. Is it a known fact that this flag is set only after the sizeHint method has been called, or am I doing something wrong?

Thanks,

Andras