Holding Alt key and scolling with the scrollwheel only scrolls one way
-
I don't know why, but whenever I hold down alt and scroll, I get 0 returned. No other key does this.
This is code from my custom GraphicsView class:
void View::wheelEvent(QWheelEvent * event) { if (keyAltDown) { std::cout << "Alt Scroll Amount: " << event->angleDelta().y() << "\n"; if (event->angleDelta().y() > 0) verticalScrollBar()->setValue(verticalScrollBar()->value() + 150 * zoomDelta); else verticalScrollBar()->setValue(verticalScrollBar()->value() - 150 * zoomDelta); } else if (keyCtrlDown) { std::cout << "Ctrl Scroll Amount: " << event->angleDelta().y() << "\n"; if (event->angleDelta().y() > 0) horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 150 * zoomDelta); else horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 150 * zoomDelta); } }
As you can see, I am printing the y() value to the console. Nothing changes except the key I hold down. When I hold Ctrl (Windows), I either get 120, or -120. When holding Alt, it's 0 both ways. Why is this happening?
BTW, I am already overriding the wheelEvent function. Doesn't work when I add override or not.
-
Hi,
What kind of values are you expecting ?
And is it alt or alt gr ?
-
@SGaist I should have clarified, that I am expecting to get 120 or -120. That's what I usually get when scrolling works successfully. I am unsure of what Alt gr is. I am just holding the left Alt key on my keyboard and this happens.
-
Alt usually serves to activate the menu accelerators. So there might be something with that.
Alt Gr is usually the one at the right.