-1

I want to set background color of a selected inactive item in a QTreeView using style sheet as follows:

MyTreeView->setStyleSheet("QTreeView::item:selected:!active { background-color: rgb(150, 180, 220) }");

But the code has no effect in the tree view, but the similar code works for QTableView.

Can anyone tell me what I'm missing here?

Thanks in advance.

Yarram
  • 115
  • 1
  • 11
  • Perhaps yet another Qt style sheets bugs. Have you tried using a different application style (e.g Fusion?) – Sergio Monteleone May 25 '18 at 15:23
  • Sorry guys. Actually there is nothing wrong in the CSS. It started working later. I have no idea why. But thanks for your time... – Yarram May 27 '18 at 19:33

1 Answers1

-1

rgb(150, 180, 220); you need the semi colon inside too.

Mike
  • 190
  • 7
  • Sorry guys. Actually there is nothing wrong in the CSS. It started working later. I have no idea why. But thanks for your time... – Yarram May 27 '18 at 19:32
  • It usually doesn't work without the semicolon inside the literal. In your case since you were only notifying one attribute it might have been fine, but rule of thumb - use semicolons in there because the compiler won't catch that for you since its part of a string literal. – Mike Jun 05 '18 at 21:21