# How to get hovering event with vtkInteractorStyle ?

**URL:** https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687
**Category:** Support
**Created:** [January 20, 2022, 9:31am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687 "2022-01-20T09:31:36Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 20, 2022, 9:31am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/1 "2022-01-20T09:31:36Z")

</div>

Hello everyone,  
I would like to interact with a vtkRenderer to pick object when I am hovering an object. Unfortunately onMouseMove (from vtkInteractorStyle) works only when a real click happens. Is there a way to have mouse hover coordinates in renderer with vtk (vtkInteractorStyle)?

Thanks for your help.

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 21, 2022, 1:16am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/2 "2022-01-21T01:16:21Z")

</div>

Maybe you should implement the hover event by yourself. `vtkPropPicker` and `vtkCellPicker` is helpful to pick a object.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 21, 2022, 7:48am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/3 "2022-01-21T07:48:24Z")

</div>

I already implemented my own picker. To give you a bit more context, I am using vtkr inside a Qt QML software, and I just want to get mouse coordinates for hovering event with vtk, maybe with onMouseMove (vtkInteractorStyle). But for now onMouseMove need a click to work.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 23, 2022, 3:15pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/4 "2022-01-23T15:15:18Z")

</div>

Hi, Julien,

Make sure to call `setMouseTracking(true)` on the Qt widget that contains your viewport. Also, if you are calling `setViewport()` on the widget, make sure to call `setMouseTracking()` **after** that.

I hope this helps,

Paulo

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 24, 2022, 8:49am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/5 "2022-01-24T08:49:52Z")

</div>

> [@Paulo\_Carvalho](#):
>
> setMouseTracking

Unfortunalety I am on a Qt quick project so I don’t have setMouseTracking(true) available for qt quick item. I tried   
`setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::AllButtons); setFlag(ItemAcceptsInputMethod, true);`  
but without success.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 24, 2022, 10:09pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/6 "2022-01-24T22:09:14Z")

</div>

Take a look at this: [[Interest] setMouseTracking() equivalent for QQuickItem?](https://lists.qt-project.org/pipermail/interest/2014-July/013102.html)

> Try enabling hover events (`QQuickItem::setAcceptHoverEvents`), they are disabled by default. Then handle them in `hoverEnter/Leave/MoveEvent()`.

(emphasis added)

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 25, 2022, 1:22pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/7 "2022-01-25T13:22:19Z")

</div>

I tried this but `hoverMoveEvent()` is never called. Can it be because of the QQuickVtkRenderItem ?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 25, 2022, 1:51pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/8 "2022-01-25T13:51:53Z")

</div>

> [@Paulo\_Carvalho](#):
>
> Try enabling hover events (`QQuickItem::setAcceptHoverEvents`), they are disabled by default.

Did you do this **before** implementing `MoveEvent()`?

> [@Julienchz](#):
>
> Can it be because of the QQuickVtkRenderItem ?

Sorry, I don’t know. I don’t work with Qt Quick. Only normal Qt.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 25, 2022, 2:54pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/9 "2022-01-25T14:54:40Z")

</div>

I did this in my QQuickVtkRenderItem constructor.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [January 27, 2022, 7:24am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/10 "2022-01-27T07:24:15Z")

</div>

But that way is not working.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 27, 2022, 12:56pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/11 "2022-01-27T12:56:21Z")

</div>

Is there any reason to set `QQuickItem::setAcceptHoverEvents` in the constructor? Can you not set it elsewhere?

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [February 7, 2022, 8:33am UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/12 "2022-02-07T08:33:41Z")

</div>

> [@Paulo\_Carvalho](#):
>
> `setAcceptHoverEvents`

There is no reason, but I can call it elsewhere and nothing change, onMouseMove is never called for hovering event.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 8, 2022, 2:00pm UTC](https://discourse.vtk.org/t/how-to-get-hovering-event-with-vtkinteractorstyle/7687/13 "2022-02-08T14:00:11Z")

</div>

Well, in you case I’d make sure you have the latest version of the API or file a bug report if you are not willing to move to normal Qt.
