3500/QMyTableViewBtnDelegate.h

31 lines
844 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef QMYTABLEVIEWBTNDELEGATE_H
#define QMYTABLEVIEWBTNDELEGATE_H
#include <QObject>
#include <QPushButton>
#include<QStyledItemDelegate>
class QMyTableViewBtnDelegate: public QStyledItemDelegate
{
Q_OBJECT
public:
explicit QMyTableViewBtnDelegate(QStringList btnNames, QWidget *parent = 0);
~QMyTableViewBtnDelegate();
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index);
signals:
void editData(const QModelIndex &index);
void deleteData(const QModelIndex &index);
private:
QPoint m_mousePoint; // 鼠标位置
int m_nType; // 按钮状态0-划过 1-按下
QStringList m_btnNames;
};
#endif // QMYTABLEVIEWBTNDELEGATE_H