//
// Created by Krad on 2021/10/11.
//

#ifndef GUI_CENTERALIGNSQLTABLEMODEL_H
#define GUI_CENTERALIGNSQLTABLEMODEL_H

#include <QSqlTableModel>
class CenterAlignSqlTableModel:public QSqlTableModel {
    Q_OBJECT
public:
    explicit CenterAlignSqlTableModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase()):QSqlTableModel(parent,db){};
    ~CenterAlignSqlTableModel(){};
protected:
    QVariant data(const QModelIndex& index, int role) const override {
        if (index.column() >0 && role == Qt::TextAlignmentRole) {
            return Qt::AlignCenter;
        } else {
            return QSqlTableModel::data(index,role);
        }
    }
};


#endif //GUI_CENTERALIGNSQLTABLEMODEL_H
