Thank you,

I've tested this by implementing a selection model class deriving from QItemSelectionModel and saw the following behavior

-1- Clicking on a Qt::ItemIsSelectable item /b/ when beeing on a Qt::ItemIsSelectable item /a/ will call:
select(const QItemSelection ... with command = 35 with selection containing the destinated selected item /b/
select(const QModelIndex ... for the destinated selected item /b/ with command = 0
select(const QItemSelection ... with command = 0 with selection containing the destinated selected item /b/


-2- Clicking on a non Qt::ItemIsSelectable /b/ item when beeing on a Qt::ItemIsSelectable item /a/ will call:
select(const QItemSelection ... with command = 35 with selection containing no item


-3- Clicking on a Qt::ItemIsSelectable item /b/ when beeing on a non Qt::ItemIsSelectable /a/ item will call:
select(const QItemSelection ... with command = 35 with selection containing the destinated selected item /b/
select(const QModelIndex ... for the destinated selected item /b/ with command = 0
select(const QItemSelection ... with command = 0 with selection containing the destinated selected item /b/


-4- Clicking a non Qt::ItemIsSelectable item when beeing on a non Qt::ItemIsSelectable item will call:
select(const QItemSelection ... is called with command = 35 with selection containing no item


So it looked like the calls of the select functions are already the result of some kind of treatment resulting in the new selection.

Finally I went to reimplement mousePressEvent and mouseReleaseEvent in order to catch the mouse events on a QModelIndex I do not want to be selectable:


Qt Code:
  1. void
  2. SideBarTree::mousePressEvent(QMouseEvent *event)
  3. {
  4. QPoint pos = event->pos();
  5. QModelIndex index = indexAt(pos);
  6. if (index.row() == SideBar::Spacer1) return;
  7. if (index.row() == SideBar::Spacer2) return;
  8.  
  9. QTreeView::mousePressEvent(event);
  10. }
  11.  
  12. void
  13. SideBarTree::mouseReleaseEvent(QMouseEvent *event)
  14. {
  15. QPoint pos = event->pos();
  16. QModelIndex index = indexAt(pos);
  17. if (index.row() == SideBar::Spacer1) return;
  18. if (index.row() == SideBar::Spacer2) return;
  19.  
  20. QTreeView::mouseReleaseEvent(event);
  21. }
To copy to clipboard, switch view to plain text mode 

This seems to work.