Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Item from QStandardItemModel for QTableView

I have a QTreeView in which each node represents a data object. I managed to pack a pointer to this data objects into a QVariant so that I know which is selected in the Tree. I can access the nodes by the currentIndex() function.

The root of the Tree is at QStandardItemModel::invisibleRootItem(). Other nodes are added by the parent nodes appendRow function. So the Items have no row and column that I can use in QStandardItemModel::item().

Is there a way to give the nodes valid coordinates or to retrieve the items without coordinates.

like image 878
Thomas Klier Avatar asked Feb 01 '26 23:02

Thomas Klier


1 Answers

In QStandardItemModel, there is a item(int row, int column = 0) method. Qt nomenclature doesn't use 'get' as prefix of getters methods.

like image 177
Antwane Avatar answered Feb 03 '26 21:02

Antwane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!