[If anyone has a better answer, I will gladly agree with him. ]
Looking at the source of QListWidget , it seems that checking the inputs is what Qt does itself:
QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) const
{
if (hasIndex(row, column, parent))
return createIndex(row, column, items.at(row));
return QModelIndex();
}
, hasIndex(), , validRowColumn().
bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent) const
{
if (row < 0 || column < 0)
return false;
return row < rowCount(parent) && column < columnCount(parent);
}
, index.isValid() , hasIndex(index.row(), index.column(), index.parent()) . , , hasIndex(QModelIndex &). hasIndex() , QModelIndex::isValid() :
inline bool isValid() const { return (r >= 0) && (c >= 0) && (m != 0); }