# Mouse over in QML project

**URL:** https://discourse.vtk.org/t/mouse-over-in-qml-project/12398
**Category:** Support
**Created:** [October 2, 2023, 12:33pm UTC](https://discourse.vtk.org/t/mouse-over-in-qml-project/12398 "2023-10-02T12:33:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ZelieR](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zelier/32/7375_2.png) [@ZelieR](https://discourse.vtk.org/u/ZelieR)
#### Post date: [October 2, 2023, 12:33pm UTC](https://discourse.vtk.org/t/mouse-over-in-qml-project/12398/1 "2023-10-02T12:33:38Z")

</div>

Hi everyone,

I’am trying to use vtk in a QML project.  
I’d like to highlight faces, edges or vertex on the mouse move hover event.

I use VTK 9.3.0.rc1

But it seems that it isn’t implemented in VTK as I can see in `QVTKInteractorAdapter::ProcessEvent`  
Almost every QEvent are handled but not `QEvent::HoverMove`.

So I’ve tried a workaround using QML: I put a `MouseArea` over my object inherited by `QQuickVTKItem`, when the `MouseArea` trigger the `onPositionChanged` it calls my function that tried to highlight what’s under the mouse using a `vtkCellPicker`.

It works for a while but suddenly it randomly crash in some VTK code, most of the time on unverified nullptr…

Here is some QML code:

```auto
    MouseArea {
        anchors.fill: stepViewer
        hoverEnabled: true
        propagateComposedEvents: true
        acceptedButtons : Qt.NoButton
        onPositionChanged: {
            mouse.accepted = false
            myVTKViewer.highlightSubPoly(mouseX, height - mouseY)
        }
    }

```

Then the code I use to highlight what I get from the picker:  
Nota: `vtkPolyData* m_polyData;`

```auto
	 // Clear selection
	 vtkIntArray* cellData = vtkIntArray::SafeDownCast(m_polyData->GetCellData()->GetScalars());
	 cellData->Fill(UNSELECTED_CELL); // <= value I use to color the unselected cells
...
	for (vtkIdType id : triIDS) // <= triIDS contains all cells I want to select
		cellData->SetValue(id, HIGHLIGHTED_CELL); // <= value I use to color the highlighted cells

	 cellData->Modified();

```

If there is any change in highlighted cells I call `scheduleRender();` from my `QQuickVTKItem`.

What did I do wrong ?  
Is there another way to achieve what I tried to do?
