[PyQt] Multiple Signals Emitted

Rapczak, Jesse jrapczak at soe.sony.com
Fri Jan 27 23:04:35 GMT 2012


I've been loading Designer UI's using uic.loadUiType and noticed that my slots were getting called twice. After some digging I discovered the use of the pyqtSlot() decorator and the possibility that all signal types are being automatically connected to the same slot. From the PyQt4 docs:

	For example, QtGui.QAbstractButton has the following signal:

		void clicked(bool checked = false);

	Qt implements this as the following:

		void clicked();
		void clicked(bool checked);

	The pyqtSlot() decorator can be used to specify which of the signals should be connected to the slot.

Am I on the right track, here? I can't seem to get pyqtSlot() to behave in the simple example of a button:


	    self.testBtn.clicked.connect(self.testFunc)


    @QtCore.pyqtSlot(bool)
    def testFunc(self, b):
        # Do what I really want

    @QtCore.pyqtSlot()
    def testFunc(self):
        pass

In the above example, the bottom function gets called twice. 

Am I on the right track? Is this why my slots are getting called twice? Any help would be greatly appreciated!

--
Jesse Rapczak


More information about the PyQt mailing list