How to change Qt selection highlight qListView

When using qlistview in icon mode, I need to completely remove hightighting when selecting an icon. Using the code below, the text below the icon no longer stands out, but I still get a blue color above the icon when I select

QString stylesheet = ""; stylesheet += "QListView::item:alternate {background-image: transparent; background-color: transparent;}"; stylesheet += "QListView::item:selected {background-image: transparent; background-color: transparent;padding: 0px;color: black;}"; stylesheet += "QListView::item:selected:active{background-image: transparent;background-color: transparent; color: black;}"; stylesheet += "QListView::item:selected:!active{background-image: transparent;background-color: transparent;color: black;}"; setStyleSheet(stylesheet); 

Does anyone know how to change the selected color above the icon without subclassing QStandardItem?

+6
highlighting selected qt icons qlistview
source share
2 answers

For QListView with QStandardItem, you can do what you want. Just create an icon, add the same pixmap for the regular and selected states. Then setIcon in the element

 QIcon icon; icon.addPixmap(yourPixmap,QIcon::Normal); icon.addPixmap(yourPixmap,QIcon::Selected); qstandardItem.setIcon(icon); 
+6
source share

Found my own answer. it was not possible to remove the section color overlay in QListview without using a delegate, but after switching to using QListWidget, I could turn off the overlay by setting the selected icon image

0
source share

All Articles