I have solved it this way in my QTreeView subclass, but there must/ought to be a way for doing this by configuring Qt objects.
void TreeView
::rowsAboutToBeRemoved ( const QModelIndex & parent,
int start,
int end
) {
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.size() == 1 && selectedRows[0].parent() == parent && selectedRows[0].row() >= start && selectedRows[0].row() <= end)
{
// the rows about to be removed contain the single selected item
selectionModel()->clear();
}
}
QTreeView::rowsAboutToBeRemoved (parent, start, end
);
}
void TreeView::rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end )
{
if (selectionMode() == QAbstractItemView::SingleSelection)
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.size() == 1 && selectedRows[0].parent() == parent && selectedRows[0].row() >= start && selectedRows[0].row() <= end)
{
// the rows about to be removed contain the single selected item
selectionModel()->clear();
}
}
QTreeView::rowsAboutToBeRemoved (parent, start, end);
}
To copy to clipboard, switch view to plain text mode
Bookmarks