PyQt5 in which module is the radiation method found?

It would be helpful if someone would run this code for me as a health check.

Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>>from PyQt5.QtCore import pyqtSignal >>>for i in dir(pyqtSignal): ... if i == 'emit': ... print(True) ... >>> 

Is true for someone else? Note that when importing a QObject from PyQt4:

 >>> from PyQt4.QtCore import QObject >>> for i in dir(QObject): ... if i == 'emit': ... print(True) ... True 
0
pyqt5 qt-signals pyqt
source share
1 answer

pyqtSignal not a signal, it is a factory function to create signals, so of course it does not have emit . It simply returns a descriptor which, when bound to a QObject instance, returns the actual signal object. This means that only the associated signal will have an emit method.

The QObject.emit method is a relic from time to time before new style signals were introduced into pyqt and has now been deleted . Just use the emit method for the associated signal to emit it:

 class SomeObject(QObject): someSignal = pyqtSignal(...) instance = SomeObject() instance.someSignal.emit(value) 
+2
source share

All Articles