When using qlistview in icon mode I need to completely remove the hilighting when a icon is selected. Using the code below the text under the icon is no longer highlighted but I still get blue color over the icon when selected
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 over the icon without having to subclass QStandardItem?
For a QListView with QStandardItem's it's possible to do what you want. Simply create an icon an add the same pixmap for both normal and selected states. Then setIcon in the item
QIcon icon;
icon.addPixmap(yourPixmap,QIcon::Normal);
icon.addPixmap(yourPixmap,QIcon::Selected);
qstandardItem.setIcon(icon);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With