-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrolling instead of zooming #23
Comments
Wow I didn't even see this. Haha it feels so great to have other people's activity on here. And yes, I've been very much looking for that. My temporary solution was to disable the mouse wheel completely. But I'll try your solution out. |
Implemented in e0a6211, works. I now realize that this does effectively the same thing as what I had before (previously all scroll events on ScrollArea were blocked, now only scroll events above the plot are blocked; which comes out as the same thing because the ScrollArea consists of nothing but said plot), but it doesn't matter :) I plan to move the text boxes to Qt text boxes anyway, which would make this change worthwhile. |
Sorry, somehow i managed to write down the opposite of what I was thinking and didn't even it realize up to now. We should make use of QWidget.hasFocus() property and/or the QWidget::focusInEvent to achieve a better result, the idea is that it will only zoom in/out if the user previously clicked on the plotwidget, otherwise it will keep out of focus and as a result not zooming. I'm a little bit rusty in PyQt but will definitely give it a try in the next weekend. |
That's a neat idea. Though I'm a little afraid that having to click onto a widget in order to be able to interact with it is unintuitive. I'll reopen this issue, I think..? |
It is bit unintuitive for sure but I guess its the standard approach in this case, if you think in a more intuitive way let me know it, I'm really interested in a new approach 🤔 |
Update: I did a big restructure of how the plots are rendered. All plots used to be embedded in one big GraphicsLayoutWidget (class from pyqtgraph). It used to be impossible to detect whether a scroll event happened on a plot or on the padding between plots - it was all part of the GraphicsLayoutWidget black box. Now, everything that can be done in Qt is done in Qt. Among fixing other issues (weird plot squashing and limited window shrinking capabilities) it made it possible to implement exactly what I described in the edited screenshot above. |
Hey,
if you want to stop scrolling when the mouse is above the plot you can overwrite the QScrollArea's eventfilter
self.scrollArea.viewport().installEventFilter(self)
and then do something like that:
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.Wheel:
if self.Plot.underMouse():
return True
I thought you might be looking for something like that.
The text was updated successfully, but these errors were encountered: