25 lines
570 B
C++
25 lines
570 B
C++
/**
|
|
*\brief 用来实现item选中时保持前景色(文字颜色)不变
|
|
*
|
|
*\author dsc
|
|
*/
|
|
|
|
#ifndef TEXTCOLORPRESERVEDELEGATE_H
|
|
#define TEXTCOLORPRESERVEDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
class TextColorPreserveDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TextColorPreserveDelegate(QObject* parent = nullptr);
|
|
~TextColorPreserveDelegate();
|
|
|
|
protected:
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
};
|
|
|
|
#endif // TEXTCOLORPRESERVEDELEGATE_H
|