I was using the delta() function from the QWheelEvent class to achieve the zoom in, zoom out. now it is deprecated, and they advise in the documentation to use pixelDelta() or angleDelta() instead, but they are QPoint objects!
can anybody please tell me how to replace this deprecated function with another ones?
void MapView::wheelEvent(QWheelEvent *event)
{
if(event->delta()>0)
{
if(m_scale < MAX_SCALE)
{
std::cout << m_scale << std::endl;
this->scale(ZOOM_STEP, ZOOM_STEP);
m_scale *= ZOOM_STEP;
}
}
else if(event->delta() < 0)
{
if(m_scale >= MIN_SCALE)
{
std::cout << m_scale << std::endl;
this->scale(1/ZOOM_STEP, 1/ZOOM_STEP);
m_scale *= 1/ZOOM_STEP;
}
}
}
The documentation of angleDelta says that angleDelta().y() will return the angle by which the vertical mouse wheel was rotated and angleDelta().x() will return the angle by which the horizontal mouse wheel was rotated.
For zooming I'm assuming you will want to use vertical scrolling, so changing the conditions accordingly gives:
void MapView::wheelEvent(QWheelEvent *event)
{
if(event->angleDelta().y() > 0)
{
if(m_scale < MAX_SCALE)
{
std::cout << m_scale << std::endl;
this->scale(ZOOM_STEP, ZOOM_STEP);
m_scale *= ZOOM_STEP;
}
}
else if(event->angleDelta().y() < 0)
{
if(m_scale >= MIN_SCALE)
{
std::cout << m_scale << std::endl;
this->scale(1/ZOOM_STEP, 1/ZOOM_STEP);
m_scale *= 1/ZOOM_STEP;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With