QModelIndex index = model->index(row, column, parent);
QModelIndex index = model->index(row, column, parent);
QModelIndex index =
model->index(row, column, parent);
http://www.kuqin.com/upimg/allimg/071113/1824252.png
上图中,A项和C项作为model中顶层的兄弟项:
QModelIndex indexA =
model->index(0, 0, QModelIndex());
QModelIndex indexC =
model->index(2, 1, QModelIndex());
A有许多孩子,它的一个孩子B用以下代码获取:
QModelIndex indexB =
model->index(1, 0,
indexA);
view会渲染model中的内容,通过model的接口来访问它的数据。当用户试图编辑数据项时,view会使用缺省的delegate来提供一个编辑构件。
构建一个table model ,它有32个项,用一个table view进行显示:
TableModel *model = new
TableModel(8, 4,
&app);//8表示为有8行,4表示有4列

加载中…