diff --git a/core/autotablemodel.h b/core/autotablemodel.h index d399f7c..3586d7c 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -95,6 +95,30 @@ public: private: QList > m_list; + + // QAbstractItemModel interface +public: + QVariant headerData(int section, Qt::Orientation orientation, int role) const + { + if (role != Qt::DisplayRole) { + return QVariant(); + } + + if (orientation == Qt::Horizontal) { + QObject *entity = (QObject*)new T(); + + for (int i = 0; i < entity->metaObject()->propertyCount(); i++) { + if (i == section) { + QString colName(entity->metaObject()->property(i + 1).name()); + return tr(colName.toStdString().c_str()); + } + } + + delete entity; + } + + return QVariant(section + 1); + } }; #endif // ODBTABLEMODEL_H