12345678910111213141516171819202122232425262728293031323334 |
- #ifndef __DELEGATE_CHECKBOX_H__
- #define __DELEGATE_CHECKBOX_H__
- #include <QStyledItemDelegate>
- class DelegateCheckBox : public QStyledItemDelegate
- {
- Q_OBJECT
- public:
- explicit DelegateCheckBox(QObject *parent = nullptr);
- ~DelegateCheckBox() override;
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const override;
- void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
- void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
- void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
- protected:
- bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
- private:
- /* 获取图片 */
- QString GetCheckboxImage(Qt::CheckState state) const;
- };
- #endif // __DELEGATE_CHECKBOX_H__
|