-
-#if 0
-
-class StringListModel : public QAbstractListModel
-{
- Q_OBJECT
-
- public:
- StringListModel(const QStringList &strings, QObject *parent = 0)
- : QAbstractListModel(parent), stringList(strings) {}
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
-
- private:
- QStringList stringList;
-};
-
-int StringListModel::rowCount(const QModelIndex &parent) const
-{
- return stringList.count();
-}
-
-QVariant StringListModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() >= stringList.size())
- return QVariant();
-
- if (role == Qt::DisplayRole)
- return stringList.at(index.row());
- else
- return QVariant();
-}
-
-
-QVariant StringListModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- if (orientation == Qt::Horizontal)
- return QString("Column %1").arg(section);
- else
- return QString("Row %1").arg(section);
-}
-
-
-
- void ImageModel::setImage(const QImage &image)
- {
- modelImage = image;
- reset();
- }
-
-The QAbstractItemModel::reset() call tells the view(s) that the model has changed.
-
-#endif