QListView with QAbstractListModel shows an empty list
问题 I have created a very simple example of QListView with a custom QAbstractListModel . The QListView is displayed but it is empty. What am I doing wrong? Code: #include <QListView> #include <QAbstractListModel> #include <QApplication> class DataModel: public QAbstractListModel { public: DataModel() : QAbstractListModel() {} int rowCount( const QModelIndex & parent = QModelIndex() ) const { return 2; } QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const { return "a"; } }