I have Qt application where I draw graphs using pyqtgraph lib and use dock containers also from pyqtgraph. So I create several dock containers and put one graph in each. Then, in my code I need to identify the graph with which user is working to update some other staff in the application (e.g. to show some properties for "active" graph in some common for all widget).
My idea is to receive mouse click signal and identify the graph where it was clicked to know the last graph user interacted. But pyqtgraph PlotWidget, PlotItem or ViewBox classes don't provide such a signals and I don't know if there is a way to implement it myself. Also, I didn't find a way to identify which dock container is active. I only see sigMouseReleased for the PlotWidget but even this doesn't work for me (see code below)
Here is my minimum code:
import sys from PyQt5 import QtCore, QtGui, QtWidgets import pyqtgraph as pg from pyqtgraph.dockarea import * # I use Qt Designer, below I just cut generated code to minimum class Ui_StartForm(object): def setupUi(self, StartForm): StartForm.setObjectName("StartForm") StartForm.resize(1507, 968) self.GraphLayout = QtWidgets.QGridLayout(StartForm) # my application class AppWindow(QtWidgets.QWidget, Ui_StartForm): def __init__(self): super(AppWindow, self).__init__() self.setupUi(self) self.dock_area_main = DockArea() self.GraphLayout.addWidget(self.dock_area_main) self.Dock1 = Dock("Dock 1", size=(1, 1)) self.dock_area_main.addDock(self.Dock1, 'left') self.Dock2 = Dock("Dock 2", size=(1, 1)) self.dock_area_main.addDock(self.Dock2, 'right') self.GraphViewList = [] self.pl1 = pg.PlotWidget() self.pl2 = pg.PlotWidget() self.Dock1.addWidget(self.pl1) self.Dock2.addWidget(self.pl2) self.pl1.sigMouseReleased.connect(self.mouse_release) # try to get some mouse event def mouse_release(self): print('click') # never execute app = QtWidgets.QApplication(sys.argv) w = AppWindow() w.show() sys.exit(app.exec_()) My question is how can I implement signal mouse clicked for pyqtgraph PlotItem or ViewBox to identify which graph was last interacted by user. Same time, it shouldn't influence functions of pyqtgraph plots (it should catch all mouse events normally)
If there is better strategy to do so - please suggest