简体   繁体   English

PyQt多个QDilaog类信号捕获

[英]PyQt multiple QDilaog class signal catching

I have a PyQt Gui application that has multiple QDialog windows that I use to plot data using matplotlib widget. 我有一个PyQt Gui应用程序,该应用程序具有多个QDialog窗口,可用于使用matplotlib小部件绘制数据。 This is the code I'm using is below. 这是我正在使用的代码如下。

Only one emitted signal is caught. 仅捕获到一个发射信号。 Which ever QDialog is created last catches it's emitted signal. 最后创建哪个QDialog会捕获其发出的信号。 If the TempBox dialog is created last the NewTemp_signal is caught, or if the RealBox dialog is created last the NewReal_signal is caught. 如果最后创建了TempBox对话框,则捕获NewTemp_signal ,或者如果最后创建RealBox对话框,则捕获NewReal_signal But, the other signal is not caught. 但是,另一个信号没有被捕获。 How do I catch both signals to update all dialogs? 如何捕获两个信号以更新所有对话框? Thanks 谢谢

Dialog window class 对话框窗口类

class GUIgraph(QtGui.QDialog):
    def __init__(self,parent=None):
       QtGui.QDialog.__init__(self,parent)
       print 'This is the Histograph dialog class function'
       self.graph = Ui_histogram_Dialog()
       self.graph.setupUi(self)

Functions that create new windwos 创建新窗口的功能

def TempgraphFunc(self):
    QtGui.QWidget.__init__(self,parent=None)
    self.TempBox = GUIgraph()
    self.TempBox.setWindowTitle("Temperature")
    self.NewTemp_signal.connect(self.TempPlotFunc)
    self.TempBox.show()

def RealgraphFunc(self):
    QtGui.QWidget.__init__(self,parent=None)
    self.RealBox = GUIgraph()
    self.RealBox.setWindowTitle("Real Space")
    self.NewReal_signal.connect(self.RealPlotFunc)
    print 'Real is connected'
    self.RealBox.show()

In another function I emit a signal 在另一个函数中,我发出信号

def loadFiles(self):
    ....
    self.NewTemp_signal.emit()
    self.NewReal_signal.emit()
    print ' signals emitted' 

I think you have architectural problems. 我认为您有体系结构问题。 I don't see all your code, but at least this is very strange: 我看不到您的所有代码,但至少这很奇怪:

def TempgraphFunc(self):
    QtGui.QWidget.__init__(self,parent=None)
    self.TempBox = GUIgraph()
    self.TempBox.setWindowTitle("Temperature")
    self.NewTemp_signal.connect(self.TempPlotFunc)
    self.TempBox.show()

In a method you are calling QtGui.QWidget.__init__ ??? 在一个方法中,您正在调用QtGui.QWidget.__init__ ??? __init__ is the parent 'constructor' method, and you are supposed to call it from a subclass overridden __init__ __init__是父级的“构造方法”,您应该从覆盖了__init__的子类中调用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM