#pragma once
|
|
#include <QStyledItemDelegate>
|
#include <QAbstractItemView>
|
#include <QEvent>
|
#include <QMouseEvent>
|
#include <QApplication>
|
#include <QObject>
|
#include <QPushButton>
|
#include <QPainter>
|
|
namespace Ripples {
|
|
// 自定义按钮委托类
|
class CustomButtonDelegate : public QStyledItemDelegate {
|
Q_OBJECT
|
public:
|
mutable QPersistentModelIndex pressedIndex; // 保持按下状态
|
mutable QPersistentModelIndex hoveredIndex; // 鼠标悬停状态
|
|
explicit CustomButtonDelegate(const QStringList& m_iconPathList, QObject *parent = nullptr);
|
|
~CustomButtonDelegate(){
|
qDebug() << "已删除";
|
}
|
|
|
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;
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
private:
|
void requestUpdate(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
private:
|
QStringList m_iconPathList;
|
|
signals:
|
void iconClicked(const QModelIndex &index);
|
|
};
|
|
|
} // namespace Ripples
|