Skip to content Skip to sidebar Skip to footer

Pyqt4 @pyqtslot: What Is The Result Kwarg For?

By reading this, two questions came up: 1. It says it is sometimes necessary to explicitly mark a Python method as being a Qt slot While I always use the @pyqtSlot decorator b

Solution 1:

  1. It is faster because of PyQt architecture. PyQt converts the python slots to C++ slots, in order to communicate with the Qt framework. When you explicitly mark a Python method as a Qt slot and provide a C++ signature for it, the PyQt code doesn't have to guess the C++ signature itself, as it is already specified. This may enhance performance on heavy projects.

  2. The return value is only needed when you want to call the slot as a normal function.

Edit: It seems that the QMetaObject.invokeMethod method executes a slot and uses it's return value.


Post a Comment for "Pyqt4 @pyqtslot: What Is The Result Kwarg For?"