权重列表模型中的索引项目

Indexing items in a Wt List Model

为什么在使用 Wt 列表模型时必须在 dataindex 方法中指定一列?

The WAbstractListModel doc 说,"An abstract list model specializes WAbstractItemModel for one-dimensional lists (i.e. a model with 1 column and no children)."

WAbstractListModel::index 原型是 index (int row, int column, const WModelIndex &parent=WModelIndex())。也有 index (int row, const WModelIndex &parent=WModelIndex()) 是不是有意义?

WStringListModel::data中也发现了同样的情况,其原型是data (int row, int column, int role=DisplayRole, const WModelIndex &parent=WModelIndex())? WStringListModel(或 WAbstractListModel 的任何实现)提供方法 data (int row, int role=DisplayRole, const WModelIndex &parent=WModelIndex()) 是不是有意义?

我意识到Wt在很多方面都是不完整的。列表模型缺少一维 API 仅仅是因为不完整吗?或者是否有一些概念上的原因需要在此处指定列号?

Response from Wt developer:

WAbstractListModel doesn't add much (besides expressing intent).

The item models and views have been modelled after those in Qt, and are in most ways the same as those provided by Qt. See for example http://doc.qt.io/qt-5/qstringlistmodel.html

Qt link 表明我的两个建议都在那里实现了。

QAbstractListModel::index不要求您指定列:

QModelIndex QAbstractListModel::index(int row, int column = 0, const QModelIndex & parent = QModelIndex()) const

而且,QStringListModel::data 没有列参数:

QVariant QStringListModel::data(const QModelIndex & index, int role) const

所以,我将其归结为 "incompleteness."