Stals Stals - 5 months ago 60
C++ Question

How to get cell value from selected row (QTableView)?

I have a

and I need to the get value (string) from the first cell of the selected row (any cell on the row could be selected). But I need this value only if exactly one row was selected.

I thought - I need to get index of the selected row and then get the value of the first сell on that line, but I couldn't find a way to do it.


Will give you the index of the currently selected row. From there you should have enough information to look up the row/column pair in your model.

Also, QItemSelectionModel::selectedRows() will let you know how many rows are selected.