Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
model view rowCount
jss193 last edited by
I am trying to understand the way in which Table Models work by doing the tutorials provided by Qt, I am facing the problem that I am not able to understand the following code lines:
int rowCount(const QModelIndex &parent = QModelIndex())const override;
Your are declaring a method (rowCount) and passing it a const of type QModelIndex pointing to a memory address (&parent) and why is equal to QModelIndex? for me this makes no sense, why pass a memory address to (neither know what parent really means or where it is, I guess it is the parent class).
Can someone (please), explain me this code?
parentif not given when calling the function will contain an invalid index.
mpergand last edited by
and passing it a const of type QModelIndex pointing to a memory address (&parent)
This not an adress, it's a reference.
rowCount is a abstract method you must implement in your QAbstractTableModel subclass.
The parent ModelIndex is only relevant in a TreeView and not use in a TableView.