The overlay is complex so I exploited "PyQt5.uic". Note that "graphicsViewObj" object is instantiated already and it is loaded from a ui file. Now I need to overwrite some method in QGraphicsView (For example. a "wheelEvent" method). A new class is inherited from a QGraphicsView to overwrite wheelEvent method. Now the problem came out, How do I connect the existing object(loaded with "uic") to my overwrited class(new QGraphicsView class)? The following code elaborate my idea:
class myQGraphicsView(QGraphicsView):
def __init__(self,container):
super(myQGraphicsView,self).__init__()
def wheelEvent(self,event):
super().wheelEvent(event)
# my change here!!!
class Window(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('window.ui',self)
self.initialize()
self.bindings()
self.myQGraphicsView = myQGraphicsView() #instantiate myQGraphicsView
self.myQGraphicsView = self.graphicsViewObj # I made this up to explain what I wanted to do
# the last line was a mistake I need to copy everything from
# 'self.graphicsViewObj' to 'self.myQGraphicsView' but with new
# overwritten method 'eventWheel'
forgive me for some flaws in my code but u get the idea.