Fusion style kept adding an extra layer of gradient to my selected item of QTreeWidget even with QSS
Unsolved
General and Desktop
-
Today when I was customizing a QTreeWidget control with stylesheet, I found that when I use Fusion style, an extra layer of gradient is added to the currently selected item when the TreeWidget has focus. I tried many ways but didn't find a way to remove this gradient layer. Is it theoretically impossible to do so?
The reason of using Fusion explicitly is because the application targets Deepin Desktop Environment, whose default QStyle "chameleon" causes more problems.
Code snippet to reproduce:
#include <QStyleFactory> #include <QApplication> #include <QTreeWidget> int main(int argc, char** argv) { QApplication a(argc, argv); QTreeWidget w; a.setStyle(QStyleFactory::create("Fusion")); w.setStyleSheet("QTreeWidget::item:selected{background-color:#0070ff}" "QTreeWidget::branch:selected{background-color:#0070ff}"); w.setColumnCount(1); w.addTopLevelItem(new QTreeWidgetItem(QStringList("Test"))); w.show(); return a.exec(); }
Environment: Manjaro Linux with KDE desktop, Qt 5.15.2