How to check if no treeitem is selected in the tree view
-
Assuming a QTreeView, I believe selectionModel() is not relevant. The inherited abstract class contains direct access to currentIndex() and the returned object contains status methods for the index.
-
@summit
@Kent-Dorfman may know more than I, but be careful: in Qt current items are not necessarily the same as selected items....You can try his way. For my part I would first have looked at
currentTreeView->selectionModel()->selectedIndexes().count() == 0
, or directly fromcurrentTreeView->selectedIndexes().count() == 0
. -
@JonB said in How to check if no treeitem is selected in the tree view:
in Qt current items are not necessarily the same as selected items....
correct, and it's also explained in the docs: https://doc.qt.io/qt-5/model-view-programming.html#current-item-and-selected-items
-
@Christian-Ehrlicher
Oh, excellenty to the reference! Current item and selected items Is that subsection new in the docs, in the past I didn't find that explanation? -
@JonB said in How to check if no treeitem is selected in the tree view:
Is that subsection new in the docs, in the past I didn't find that explanation?
It's already there since some years... :)
https://doc.qt.io/archives/qt-4.8/model-view-programming.html