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:
void
{
if (index.row() == SideBar::Spacer1) return;
if (index.row() == SideBar::Spacer2) return;
}
void
{
if (index.row() == SideBar::Spacer1) return;
if (index.row() == SideBar::Spacer2) return;
}
void
SideBarTree::mousePressEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
QModelIndex index = indexAt(pos);
if (index.row() == SideBar::Spacer1) return;
if (index.row() == SideBar::Spacer2) return;
QTreeView::mousePressEvent(event);
}
void
SideBarTree::mouseReleaseEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
QModelIndex index = indexAt(pos);
if (index.row() == SideBar::Spacer1) return;
if (index.row() == SideBar::Spacer2) return;
QTreeView::mouseReleaseEvent(event);
}
To copy to clipboard, switch view to plain text mode
This seems to work.
Bookmarks