How to get hovering event with vtkInteractorStyle ?

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.

1 Like

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

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.

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

1 Like

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.

Take a look at this: [Interest] setMouseTracking() equivalent for QQuickItem?

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

(emphasis added)

1 Like

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

Did you do this before implementing MoveEvent()?

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

I did this in my QQuickVtkRenderItem constructor.

But that way is not working.

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

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

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.