How to use ItemSelectionModel with TableView
Unsolved
QML and Qt Quick
-
I have created a TableView in QML, connected to a SortFilterProxyModel. The data displays fine, and when I click on a row my "selectRow" function runs, and receives the correct row number. However, nothing shows as selected. I based my design on this Stack Overflow question
The relevant code is:
ItemSelectionModel { id: companyTableISM model: companySFPM } function selectRow(row) { console.log("In selectRow row "+row); companyTableISM.select(companySFPM.index(row, 0), ItemSelectionModel.select | ItemSelectionModel.current ); console.log(companyTableISM.selectedIndexes); console.log(companyTableISM.hasSelection); }
So when I click a row it outputs:
qml: In selectRow row 3 qml: [] qml: false
Since my selectRow function is receiving the correct row number, the model (companySFPM) matches the one used by the TableView, why do my 2 log statements showing nothing selected and false (hasSelection)?
-
@ocgltd said in How to use ItemSelectionModel with TableView:
ItemSelectionModel.select | ItemSelectionModel.current
It should be
ItemSelectionModel.Select | ItemSelectionModel.Current