It is really difficult for me to connect slots from Pythonto Qt Designer UIfiles. I went through all the tutorials that I could find on PySide(for example: http://zetcode.com/gui/pysidetutorial/eventsandsignals/ )
It's quite simple when you customize the GUI in code, but we really would like to use the Qt Designer and UI files.
Some other threads just point to using pyuicto convert files .uito .py, but if possible, I'd really like to do this at runtime.
Here is my code. I do not know how to connect connectBtnto Connectin the user interface file:
def initUI(self):
loader = QUiLoader()
file = QFile("designer_test.ui")
file.open(QFile.ReadOnly)
myWidget = loader.load(file, self)
file.close()
layout = QtGui.QVBoxLayout()
layout.addWidget(myWidget)
self.setLayout(layout)
connectBtn = QtGui.QPushButton("Connect", self)
connectBtn.clicked.connect(self.connectClicked)
myWidget.setWindowTitle('Window')
myWidget.show()
def connectClicked(self):
print("works")