<span style="font-family: courier new,monospace;">Hello,</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">I've created a simple window in Designer but can't get the connectSlotsByName function to connect up the button correctly when I've loaded the UI with uic.loadUi. I can connect the button manually, or I can use pyuic and it works, but I can't for the life of me figure out why this won't connect. I've looked all through the mailing list archives and google, but no I can't find my way out of it.</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The code is attached, with relevant sections below.</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Here's the relevant code with loadUi:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class TestWindow (QtGui.QMainWindow):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def __init__(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> QtGui.QMainWindow.__init__(self)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.ui = uic.loadUi("test.ui")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> QtCore.QMetaObject.connectSlotsByName(self)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> #self.ui.maxButton.clicked.connect(self.on_maxButton_clicked)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.ui.show()</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> @QtCore.pyqtSlot()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def on_maxButton_clicked(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print("max!")</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Here is the working bit done with a file created by pyuic:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">import testui</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class TestWindow (QtGui.QMainWindow):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def __init__(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> QtGui.QMainWindow.__init__(self)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.ui = testui.Ui_MainWindow()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> self.ui.setupUi(self)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.show()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> @QtCore.pyqtSlot()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def on_maxButton_clicked(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> print("max!")</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br><br>Thanks,<br>Peter O'Malley<br style="font-family: courier new,monospace;">