PDA

View Full Version : styling focus rect in QTreeView



roxton
8th March 2013, 21:41
Hello! I need an advice :)
Is there a way to change the view of focus rect (dotted) around the active row? I have a descendant of QTreeView with the multiseleciton, custom drawRow() and reimplemented keyboard handling. I need to make a good visible current row (not the active item), but I cannot find how to do that right. Yes, I can change the font color/height via QStyleOptionViewItem in drawRow. And that's all. I cannot define the custom background, I cannot change the focus rect around the current row.
item:selected:active is not the solution because I have many items selected and the "current cursor position" is the current item (currentIndex()) that is not selected by default in my QTreeView subclass.

wysota
8th March 2013, 22:03
Is there a way to change the view of focus rect (dotted) around the active row?
Yes.

but I cannot find how to do that right.
Either have a custom delegate or use style-sheets.


item:selected:active is not the solution because I have many items selected and the "current cursor position" is the current item (currentIndex()) that is not selected by default in my QTreeView subclass.

That's ::item:active, isn't it?

roxton
9th March 2013, 12:11
That's ::item:active, isn't it?

Unfortunately, item:active affects all rows in QTreeView (I don't know why its happen). For example:

MyTreeView::item:active {background-color: blue;}

With such style, all rows will have blue background, and current row has the default white background.
So, as you suggets, I will look to the item delegation.