简体   繁体   English

QListView具有两种不同颜色的行背景

[英]QListView with row background in two different colors

I use QListView (in PyQt5) to display strings. 我使用QListView (在PyQt5中)显示字符串。 I want to have the background color of each item in that list changing between two colors to make it easier to read. 我希望该列表中每个项目的背景色在两种颜色之间变化,以使其更易于阅读。

I tried Qt.DecorationRole but this only create an "icon" on the left side of each item. 我尝试了Qt.DecorationRole但这只会在每个项目的左侧创建一个“图标”。

self. 自。 listWidget.setAlternatingRowColors(True) this will give you Alternate color for each row. listWidget.setAlternatingRowColors(True)这将为您提供每行的备用颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据 2 种不同条件更改 Pandas Row 背景颜色和字体颜色 - change Pandas Row background colour and Font Colors based on 2 different conditions 我如何使用pyqt4将不同的背景颜色应用于树小部件中父文本的每一行 - How can i apply different background colors to each row of the parent text in tree widget using pyqt4 如何在 csv 文件的特定行中为不同的字符串值使用多个背景 colors - How to use multiple background colors for different string value in a particular row of csv file 后台工作人员填充 QListView 缩略图 - Background worker populate QListView thumbnails 在python中绘制具有不同背景颜色的曲线 - Plotting a curve with different background colors in python Seaborn clustermap 与两个 row_colors - Seaborn clustermap with two row_colors Polarplot:要绘制的两个列表的不同颜色 - Polarplot: different colors for the two list to be plotted 如何将 OpenCV 中的两个位掩码与不同的 colors 合并 - How to merge two bitmasks in OpenCV with different colors 在Python中绘制两个具有不同颜色的DataFrame列 - plotting two DataFrame columns with different colors in python matplotlib在同一个注释中有两种不同的颜色 - matplotlib two different colors in the same annotate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM