Skip to content

Instantly share code, notes, and snippets.

@amoe
Created March 4, 2019 16:05
Show Gist options
  • Save amoe/bb73bdeb73f6b240214057d70fcb96d4 to your computer and use it in GitHub Desktop.
Save amoe/bb73bdeb73f6b240214057d70fcb96d4 to your computer and use it in GitHub Desktop.
wrapper for stringlistmodel
#include "field_encoder_model.hh"
FieldEncoderModel::FieldEncoderModel() {
QStringList available = {"foo", "bar", "baz"};
this->innerModel = new QStringListModel(available);
}
Qt::ItemFlags FieldEncoderModel::flags(const QModelIndex& index) const {
return this->innerModel->flags(index);
}
int FieldEncoderModel::rowCount(const QModelIndex& parent) const {
return this->innerModel->rowCount(parent);
}
int FieldEncoderModel::columnCount(const QModelIndex& parent) const {
return this->innerModel->columnCount(parent);
}
QVariant FieldEncoderModel::data(const QModelIndex& index, int role) const {
return this->innerModel->data(index, role);
}
QVariant FieldEncoderModel::headerData(int section, Qt::Orientation orientation, int role) const {
return this->innerModel->headerData(section, orientation, role);
}
QModelIndex FieldEncoderModel::index(int row, int column, const QModelIndex& parent) const {
return this->innerModel->index(row, column, parent);
}
QModelIndex FieldEncoderModel::parent(const QModelIndex& index) const {
return this->innerModel->parent(index);
}
@amoe
Copy link
Author

amoe commented Mar 4, 2019

field_encoder_model.cc: In member function ‘virtual int FieldEncoderModel::columnCount(const QModelIndex&) const’:
field_encoder_model.cc:17:48: error: ‘virtual int QAbstractListModel::columnCount(const QModelIndex&) const’ is private within this context
     return this->innerModel->columnCount(parent);
                                                ^
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QModelIndex:1:0,
                 from field_encoder_model.hh:5,
                 from field_encoder_model.cc:1:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qabstractitemmodel.h:410:9: note: declared private here
     int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
         ^~~~~~~~~~~
field_encoder_model.cc: In member function ‘virtual QModelIndex FieldEncoderModel::parent(const QModelIndex&) const’:
field_encoder_model.cc:33:42: error: ‘virtual QModelIndex QAbstractListModel::parent(const QModelIndex&) const’ is private within this context
     return this->innerModel->parent(index);
                                          ^
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QModelIndex:1:0,
                 from field_encoder_model.hh:5,
                 from field_encoder_model.cc:1:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qabstractitemmodel.h:409:17: note: declared private here
     QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
                 ^~~~~~
Makefile:400: recipe for target 'field_encoder_model.o' failed
make: *** [field_encoder_model.o] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment