0

I have a PyQt Gui application that has multiple QDialog windows that I use to plot data using matplotlib widget. 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. 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. 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' 
4

1 回答 1

0

我认为你有架构问题。我没有看到你所有的代码,但至少这很奇怪:

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()

在您正在调用的方法中QtGui.QWidget.__init__???__init__是父“构造函数”方法,你应该从重写的子类中调用它__init__

于 2013-03-22T08:32:25.787 回答