Shiboken - Signals don't work
Solved
Language Bindings
-
I'm creating a thin c++ wrapper around QtAV and generating bindings for the wrapper with Shiboken.
// VideoPlayer header file Q_SIGNALS: void positionChanged(qint64 position);
// VideoPlayer constructor m_player = new QtAV::AVPlayer(this); connect(m_player, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
My problem is that Shiboken doesn't seem to know about signals, the
positionChanged
attribute appears to be a plain function and as a result I get this error message:Traceback (most recent call last): File "sandbox.py", line 48, in <module> window = MainWindow() File "sandbox.py", line 19, in __init__ self.player.positionChanged.connect(self._onPositionChanged) AttributeError: 'builtin_function_or_method' object has no attribute 'connect'
-
Turns out Shiboken shouldn't do anything for signals and let PySide setup the signals using the MOC data. Shiboken generates bindings for signals as if they were plain methods and shadows the actual signals. I ended up wrapping the signals with an ifdef:
#ifndef BINDINGS_H Q_SIGNALS: void positionChanged(qint64 position); #endif