Selected QListWidgetItem without changing text color

旧街凉风 提交于 2020-01-07 08:27:19

问题


I've got qListWidget with some items which have different text colors. I want to change background color of selected item without touching color of text. I tried with styleSheet but then all selected items has same colors. It is posible to select item without changing color of the text?


回答1:


Try to use item->setData(Qt::BackgroundRole, QBrush(color));.



来源:https://stackoverflow.com/questions/18035707/selected-qlistwidgetitem-without-changing-text-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!