Reputation: 369
I want to change the text color of the items in QListWidget
.
For example, some items are in red text while others are in blue text. How do I do that? Thank you.
Upvotes: 16
Views: 32324
Reputation: 16121
This can also be done by stylesheets. E.g.:
QListWidget::item {
color:#00ff00;
background-color:transparent;
}
Set it by setStylesheet(...)
Upvotes: 2
Reputation: 5785
QListWidget t;
t.addItem("first");
t.addItem("second");
t.item(0)->setForeground(Qt::red);
t.item(1)->setForeground(Qt::blue);
Upvotes: 21