如何启用PyQt5 eventFilter处理与另一个进程的管道连接?

问题描述

代码很长很复杂,所以我不能真正粘贴所有内容。但是,基本问题如下:我有一个在主线程和主进程中运行的GUI。该GUI安装了eventFilter,以使用subprocessing.Process启动另一个窗口。这很好。但是,子窗口有一个单独的eventFilter,必须修改原始的“父”对象。如何将pipe.send()连接或queue.put()传递给子eventFilter?除了self,source和event,它不需要任何其他参数。

与该问题有关的相关片段:

主要过程:

def listenForPad(self,pipe3_out):
    while True:
        data = pipe3_out.recv()
        if data == "SIGNAL":
            self.updateTime = t.time()
        else:
            pass

def runVCP(x1,y1,x2,y2,selection,pipe3_in):
    app = QtWidgets.QApplication(sys.argv)
    ui = VirtCP.MouseTracker(x1,pipe3_in)
    ui.show()
    sys.exit(app.exec_())    

def openTracker(self):
    
    pipe3_in,pipe3_out = Pipe()
    
    selection = self.selectedKnob
    x1 = self.dial_TL.value()
    y1 = self.dial_TR.value()
    x2 = self.dial_BL.value()
    y2 = self.dial_BR.value()
    
    dispatcher = Process(target=runVCP,args=(x1,pipe3_in),)
    dispatcher.start()
    
    t2 = Thread(target=self.listenForPad,args=(pipe3_out,))
    t2.start()

然后在子过程中:

def eventFilter(self,source,event,pipe3_in):     
    if event.type() == QtCore.QEvent.MouseMove:
        if event.buttons() == QtCore.Qt.LeftButton:
            x1 = event.x()
            y1 = event.y() 
            (...)
            pipe3_in.send("SIGNAL")

以上操作无效,因为子事件过滤器不会将pipe3_in作为参数。我想念什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)