1 回答

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以使用 pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent.double() 來查看 MouseClickEvent 是否是雙擊。
您確定坐標(biāo)不正確嗎?坐標(biāo)系從左上角的 (0,0) 開始。
試試這個(gè)代碼,它對(duì)我有用:
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.dockarea import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import QtCore, QtGui, QtWidgets, uic
import numpy as np
def on_double_click_out(event):
mouseEvent = event[0]
mousePoint = mouseEvent.pos()
if mouseEvent.double():
print("Double click")
if p.p1.sceneBoundingRect().contains(mousePoint):
print('x=', mousePoint.x(), ' y=', mousePoint.y())
class Plotter():
def __init__(self):
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
self.win = pg.GraphicsLayoutWidget(show=True)
self.win.resize(1000,500)
self.win.setWindowTitle('pyqtgraph example: dockarea')
self.p1 = self.win.addPlot()
self.win.show()
p = Plotter()
proxy = pg.SignalProxy(p.win.scene().sigMouseClicked, rateLimit=60, slot=on_double_click_out)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
您還可以查看 pyqtgraph 示例“crosshair.py”。
添加回答
舉報(bào)