Using the value of an existing style sheet element as the value of another

  • I am attempting to set the style sheets on my QTreeView such that the selected item has the same colour regardless of whether or not the view has focus. I'm doing it using

    @QTreeView::item:selected:!active { 
        background: myColour; 

    Instead of passing a hard-coded value into my style sheet, I'd like to use the value of


    allowing me to always have the colour set correctly. I had a quick go at this with

    @ QTreeView::item:selected:!active {
    background: QTreeView::item:selected:active;

    just to see what happened, which was nothing. How can I extract the value of


    and use it in my style sheet?

  • I don't think this is possible.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.