#ifndef BUTTONDELEGATE_H
#define BUTTONDELEGATE_H

#include <QStyledItemDelegate>
#include <QWidget>
#include <QHBoxLayout>
#include <QPushButton>
#include <QModelIndex>
#include <QAbstractItemModel>
#include <QPainter>
#include <QStyleOptionViewItem>
#include <QStyleOptionButton>
#include <QApplication>
#include <QTableView>
#include <QMouseEvent>
#include <QDebug>

class ButtonDelegate: public QStyledItemDelegate{
    Q_OBJECT

public:
    explicit ButtonDelegate(int buttonColumn,QObject *parent = nullptr);

    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

    bool editorEvent(QEvent *event, QAbstractItemModel *model,const QStyleOptionViewItem &option, const QModelIndex &index) override;

    void handleButtonClick(int row, int button);

private:
    int buttonColumn; // 成员变量
signals:
    void buttonClicked(int row, int button);

};



#endif // BUTTONDELEGATE_H
