/** *\brief 用来实现item选中时保持前景色(文字颜色)不变 * *\author dsc */ #ifndef TEXTCOLORPRESERVEDELEGATE_H #define TEXTCOLORPRESERVEDELEGATE_H #include 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