Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想更改QListWidget. 例如,一些项目是红色文本,而其他项目是蓝色文本。我怎么做?谢谢你。
QListWidget
QListWidget t; t.addItem("first"); t.addItem("second"); t.item(0)->setForeground(Qt::red); t.item(1)->setForeground(Qt::blue);
这也可以通过样式表来完成。例如:
QListWidget::item { color:#00ff00; background-color:transparent; }
通过setStylesheet(...)设置它