Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Fusion style kept adding an extra layer of gradient to my selected item of QTreeWidget even with QSS

Fusion style kept adding an extra layer of gradient to my selected item of QTreeWidget even with QSS

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 210 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RigoLigo
    wrote on last edited by RigoLigo
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved