Mouse wheel scrolling qml
-
i have a code in my program that play zoom_in and zoom_out role by changing scale value of my main rectange
i want to change plus and minus event key by mouse wheel up and down scrolling...i test delta function but this function can not detect up scrolling from down scrolling...can you help me? thanks!Keys.onPressed: { if (event.key == Qt.Key_Plus) { world.scale= world.scale + 0.01; } if (event.key == Qt.Key_Minus) { if(world.scale>0.009999999999999247)world.scale= world.scale - 0.01; } }
-
Hi,
If i get you correctly you want to zoom in and zoom out the rectangle using the mouse scroll. You can use MouseArea's onWheel event.
Refer "photosurface":http://doc.qt.digia.com/qt-5.1/qtquick/demos-photosurface-photosurface-qml.html for a working example. -
You can look at the onWheel signal of MouseArea. This will help you.
-
Hi,
Check wheel.angleDelta.y it gives positive or negative value depending upon scroll direction, hence you can check it's scroll up or down.