我想连接类A,B和C,这样当我在B类中按下一个按钮时,我就可以在A类中打开C类(隐藏)。
我试过这样的事情:
class A(QMainWindow):
def __init__(self):
QMainWindow.__init__()
self.tabWidget.addTab(self.tab) #I've got this from QDesigner
self.c = C()
self.c.hide() #I want to open it when i push a button
self.splitter = QSplitter(Qt.Vertical)
self.splitter.addWidget(self.c)
self.splitter.addWidget(anotherWidgets)
self.layout = QHBoxLayout()
self.layout.addWidget(self.splitter)
self.tab.setLayout(self.layout)
class B(QMainWindow): #This is a matplotlib figure and i added
#a button in the toolbar of matplotlib
def__init__(self):
#A lot of stuff in here
def openC(self):
self.button = QPushButton("Open")
self.connect(self.button, SIGNAL("clicked()", self.openWindow)
def openWindow(self):
a = A()
a.c.show()
class C(QDialog):
pass #This is QDialog that is shown when i click in the button
#of the toolbar in the matplotlib figure
所以,我想通过单击在B类中创建的按钮(matplotlib图)打开/显示QDialog(C类),并且我需要在A类(主窗口)中显示。在此之后,我可以创建另一个按钮来关闭/隐藏它。
我怎样才能做到这一点?希望你能帮帮我