Unsolved Getting compliation error in using connect in pyqt4
-
I have 2 objects in a class
QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))
I have my own customised signal and I want to send the list from one object to other object
I am getting following error
QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))
TypeError: SLOT(str): argument 1 has unexpected type 'instancemethod'Could you please let me know how correct the compilation issue
-
@Qt-Enthusiast said in Getting compliation error in using connect in pyqt4:
QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData)) TypeError: SLOT(str): argument 1 has unexpected type 'instancemethod'
Your
QtCore.SIGNAL("...")
correctly takes a string parameter. In yourQtCore.SLOT(self.metricsTreeView.clipboardData)
you are passing a method/callable instead of a string. Doesn'tQtCore.SLOT()
require a string likeQtCore.SIGNAL()
does? I suspect you intend:QtCore.QObject.connect(self.voTreeView, QtCore.SIGNAL("copySignal(list)"), self.metricsTreeView, self.metricsTreeView.clipboardData)
You probably already know that you would benefit from moving to PyQt5. But even later versions of PyQt4 introduced support for new-style signal/slots, which would have helped here. Is this legacy code which is no longer actively developed?
-
https://paste.ofcode.org/eG2QgwngRbwJdq933jdKS3
Not working . Can u some one tell the solution
t](image url)
-
@Qt-Enthusiast
Since your latest code paste uses new-style signal/slot syntax forconnect()
, why did you bother asking about your old-styleQtCore.QObject.connect(...)
code? -
@Qt-Enthusiast
In your pasted code:t1.mysignal = QtCore.pyqtSignal(list)
How is this setting a class variable? It is setting an instance variable, while you need it to be a class variable in
class Test
.