I have a QTreeView populated by a QAbstractItemModel subclass, allowing leaf nodes to be checked by the user. If a proper subset of the descendant leaf nodes of a non-leaf node are checked, then that node is partially checked (Qt::CheckStateRole is Qt::PartiallyChecked).
Currently if the user clicks on a partially checked node then the check state changes to Qt::Checked; I want it to clear the node instead (Qt::Unchecked). Is there a way to customise this behaviour? To control this with a QCheckBox I would override QAbstractButton::nextCheckState(), but I can't find anything similar for QTreeView.
Implement desired behaviour in you model setData
So when you receive in value a Qt::PartiallyChecked. You traverse item childs to set to Qt::Unchecked, and also change current item.