Disable mouse wheel scroll on QscrollArea

1,271 views
Skip to first unread message

Nedo Bianchi

unread,
Oct 14, 2017, 9:39:03 AM10/14/17
to pyqtgraph
Hi, I would like to simply disable mouse wheel scroll on QScrollArea, in order to scroll down only by clicking on right scrollbar, but I can't find any solution on the Internet.

app = QtGui.QApplication([])
sa = pg.QtGui.QScrollArea()
screen_resolution = app.desktop().screenGeometry()
scwidth, scheight = screen_resolution.width(), screen_resolution.height()

win = pg.GraphicsWindow()
win.setFixedHeight((scheight*1740)/1080)
win.setFixedWidth(scwidth-20)
win.addViewBox()
sa.setWindowTitle("Meteo Station Graph")
sa.setWidget(win)
sa.showMaximized()
pg.setConfigOptions(antialias=True)

The problem is that I have a lot of graphs in my scroll area, and when I try to mousewheel on one of them, the page will scroll up or down together with the graph.

Thank you in advance if you can help me with this problem.

Nedo Bianchi

unread,
Oct 14, 2017, 11:34:32 AM10/14/17
to pyqtgraph
I just managed to resolve the Issue creating a class:

class Scroller(pg.QtGui.QScrollArea):

def __init__(self):
pg.QtGui.QScrollArea.__init__(self)

def wheelEvent(self, ev):
if ev.type() == QtCore.QEvent.Wheel:
ev.ignore()

app = QtGui.QApplication([])
sa = Scroller()

screen_resolution = app.desktop().screenGeometry()
scwidth, scheight = screen_resolution.width(), screen_resolution.height()

win = pg.GraphicsWindow()
win.setFixedHeight((scheight*1740)/1080)
win.setFixedWidth(scwidth-20)
sa.setWindowTitle("Meteo Station Graph")
sa.setWidget(win)
sa.showMaximized()
pg.setConfigOptions(antialias=True)


 I dunnò if this is the most correct way, but I think it's really simple
 
Reply all
Reply to author
Forward
0 new messages