Hi all, I would like to know if it is possible to have a TreeView widget displaying check boxes only on some nodes. Up to now I tried subclassing QAbstractItemModel in this way:

Qt Code:
  1. Qt::ItemFlags MyModel::flags ( const QModelIndex & index ) const
  2. {
  3. if (index.isValid())
  4. {
  5. MyNode* node = static_cast<MyNode*>(index.internalPointer());
  6. if (node->needsCheckbox())
  7. return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
  8. }
  9.  
  10. return Qt::NoItemFlags;
  11. }
To copy to clipboard, switch view to plain text mode 

but the only result I got is that all nodes have a checkbox, and the ones that fail the node->needsCheckbox() method looks greyed out.

Do I need a custom delegate?

Thanks in advance...