Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTreeView selected item color when out of focus... style...



  • Hey

    I'm losing my mind... which style parameter do I have to edit to control the color of item when the widget loses focus? Apparently it changes from x to y for some reason...

    Also... if I do show-decoration-selected: 1;
    How do I control decoration color ?

    TIA


  • Moderators

    which style parameter do I have to edit to control the color of item when the widget loses focus?

    QTreeView::item:active { color: red; }   /*  When widget has focus*/
    QTreeView::item:!active { color: blue; } /*  When widget doesn't have focus*/
    

    if I do show-decoration-selected: 1; How do I control decoration color ?

    It depends on the platform styling. For example on Windows it only colors on hover the little arrow that expands/collapses the branch and that arrow is painted by a system style call so you can't control its color. You can however replace the system styling and change the branch images to your own with any color you like. See Customizing QTreeView for examples.