QTreeView/Widget selection highlight
-
A simple Google Search easily turns up how to remove the dotted/dashed rectangle around tree items. I have a more sinister question - how can I remove the blue background highlight for the currently selected item? I'm attempting to use a tree widget paired with a stack to simulate tabs with a tree structure. Everything works great, but visually that blasted blue background is still there for the currently selected item and I haven't yet been able to remove it.
Source code for my combined widget lives here https://github.com/greg-hellings/qtreetabs-qt5 - any assistance or advice on how I might get rid of that blue background would be appreciated.
-
Hi and welcome to devnet,
Should your item be selectable ?
-
Thanks!
Yes, they should be selectable. The tree represents the vertical depiction of the TabBar. I'm indicating the currently selected/active tab by use of other styling mechanisms. These primarily involve shading the rest of the background, modifying the border, etc to mimic a normal tab structure. However, that blue bar keeps hanging around. Here's the picture of what I currently have - it's the blue on the left, which is the background bleeding through, which I want to get rid of:
http://pictures.thehellings.com/screenies/bluebackground.png
-
Then you can use a QStyledItemDelegate where you ensure that the painting options doesn't contain QStyle::State_Selected
-
I have been down this path a little ways before, though I didn't know very much of what I was doing back then. Tried it again now that I know very slightly more. Amusingly, this had the opposite effect of what I wanted - it cleared out my custom stylesheet based on the :selected pseduoclass but left the blue background in place.
http://pictures.thehellings.com/screenies/styledoverride.png
-
Can you show your code ?