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

2016-01-28 Thread Tony Rietwyk
> Sent: Friday, 29 January 2016 2:45 PM
> 
> 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

Hi Nicolas, 

I think that you will need to use WA_TransparentForMouseEvents, and then
handle the MouseDown event in MyTreeView to check where along the row the
user has clicked to see if it is within the button.  

Regards, 

Tony


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


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

2016-01-28 Thread Elvis Stansvik
Den 29 jan 2016 4:47 fm skrev "Nicolas Jäger" :
>
> 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.

This is just a random guess, and would probably be a hacky solution, but
maybe you can override mouseMoveEvent on your button (subclass
QPushButton), and in the event handler also send a mouseMoveEvent to the
item under the button (using QcoreApplication::sendEvent? , before calling
the base class implementation?

On the phone now so haven't checked if this is at all doable, just an idea.

Elvis

>
> I don't know if it can be helpful, but the `QTreeView` is inherited to
MyTreeView, and this class
> contains the `QPushButton`
>
>
> regards,
> Nicolas
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


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

2016-01-28 Thread Nicolas Jäger
Hi,
> I think that you will need to use WA_TransparentForMouseEvents, and then
> handle the MouseDown event in MyTreeView to check where along the row the
> user has clicked to see if it is within the button.  

in that case I won't really clicked on the button right? in that case I won't 
have the css 
QPushButton:clicked{...}
used, right ?

today I try to figure, without success, if it would be possible to add some 
custom sub-controle like
the `hover`, and to set the sub-control from the code. For example, if I could 
have:

MyTreeview:item:WasLastSelected{ color-background: red}

since in MyTreeView object I have an eventFilter linked to the button, I can 
detect when my mouse
move over the button. So, if when this event is triggered I could set 
WasLastSelected = true

it would solved my problem (it's a guess, but I guess, it's a good guess)

Regads,
Nicolas
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


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

2016-01-28 Thread Nicolas Jäger
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
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


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

2016-01-28 Thread Nicolas Jäger
I may have found one solution:
http://doc.qt.io/qt-5/qtreewidget.html#setItemWidget

I'll look more at this tomorrow.

regards,
Nicolas
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest