Skip to content

Commit aad1d22

Browse files
committed
listview: fix text color in delegate #34
1 parent 51bdad6 commit aad1d22

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fm/src/mainwindow.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class IconViewDelegate : public QItemDelegate
9191
painter->fillRect(option.rect, option.palette.highlight());
9292
painter->setPen(option.palette.highlightedText().color());
9393
} else {
94-
painter->setPen(option.palette.text().color());
94+
QBrush txtBrush = qvariant_cast<QBrush>(index.data(Qt::ForegroundRole));
95+
painter->setPen(txtBrush.color());
9596
}
9697

9798
painter->drawPixmap(iconRect, icon.pixmap(iconsize.width(),iconsize.height()));
@@ -122,7 +123,8 @@ class IconListDelegate : public QItemDelegate
122123
painter->fillRect(option.rect, option.palette.highlight());
123124
painter->setPen(option.palette.highlightedText().color());
124125
} else {
125-
painter->setPen(option.palette.text().color());
126+
QBrush txtBrush = qvariant_cast<QBrush>(index.data(Qt::ForegroundRole));
127+
painter->setPen(txtBrush.color());
126128
}
127129

128130
painter->drawPixmap(iconRect, icon.pixmap(iconsize.width(),iconsize.height()));

0 commit comments

Comments
 (0)