c++ - Selecting a row in QTreeView programmatically -
i have qtreeview qfilesystemmodel model.
the qtreeview has selectionbehavior set selectrows.
in code read dataset select , select them via:
idx = treeview->model()->index(search); selection->select(idx, qitemselectionmodel::select);
this selects cell, not row . .
have added stupid workaround, rather fix correct way.
for (int col=0; col< treeview->model()->columncount(); col++) { idx = treeview->model()->index(search, col); selection->select(idx, qitemselectionmodel::select); }
or ^^ way it?
you can select entire row using qitemselection:
selection->select ( qitemselection ( treeview->model ()->index (search, 0), treeview->model ()->index (search, treeview->model ()->columncount () - 1)), qitemselectionmodel::select);
also if want row selection user clicks need set selection behavior:
treeview->setselectionbehavior (qabstractitemview::selectrows)
Comments
Post a Comment