[Interest] how to add a buton to the hovered item from a qtreeview

Nicolas Jäger jagernicolas at legtux.org
Fri Jan 29 04:44:31 CET 2016


Hi
I have a `QTreeView`, I control the background colors of items trough a css. When the pointer is
over an item his background is greyed.

I use the signal `entered` to detect which item, aka `QModelIndex`, aka row, is hovered. If I use
that signal, is because I have to show a `QPushButton` over a part of the row, the position of the
button is at the very right of the row though.

If no row is hovered, then the button is hidden.

The click event is related trough the actual hovered row.

so far so good, all is working but one thing, the background color. When I move the pointer over
the button, the treeview set the row behind the button to "not hovered". I used the paint function
in the past, but because of some narrow minded people forcing me to set the background in the
css stylesheet, I'm facing that issue...

using the attribute `WA_TransparentForMouseEvents` can't help since I need to click on the button.

so any idea, is welcome.

I don't know if it can be helpful, but the `QTreeView` is inherited to MyTreeView, and this class
contains the `QPushButton`


regards,
Nicolas



More information about the Interest mailing list