Unsolved model view rowCount
-
Hello!
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?
Thank you!
-
Hi,
parent
if not given when calling the function will contain an invalid index. -
@jss193 said in model view rowCount:
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.