Platform: Centos 6 & Python 2.6.6
After looking at every example and question about doing this, for the life of me I can't get it to work on my system. Most answers seem to revolve around using PyQt instead of PySide, which isn't an option for me: I gotta use what the company gives me.
Here is the code snippet from my main GUI application:
from PySide import QtCore, QtGui
class MyGui( QtGui.QMainWindow ):
@QtCore.Slot( dict )
def MySlot( self, data ):
CodeThatUsesData()
And the module that emits the signal:
from PySide.QtCore import *
from PySide.QtGui import *
class QListener( QThread ):
MySignal = Signal( dict )
def DoSomeWork( self ):
data = {'a':1, 'b':2}
self.MySignal.emit( data )
And of course I've got code that connects the signal and the slot:
listener.MySignal.connect( gui.MySlot )
And the error I get when DoSomeWork()
is called (specifically at the emit()
line) is this:
QObject::connect: Cannot queue arguments of type 'object'
(Make sure 'object is registered using qRegisterMetaType().)
From what I've read, this should totally work. More frustrating is I've found PySide documentation alluding to the use of qRegisterMetaType, but I can't find out where to call it from. It isn't in QtCore or QtGui, or stand-alone, or a member of QMainWindow or QThread or QObject.
So how do I register 'object' as a valid type for passing via the Signal/Slot paradigm? I've even tried wrapping the dictionary inside a QObject class, and that removes the registration error but the Slot operation is never called, so I don't know where the data is actually going.
I feel like the solution is slapping me in the face, but I can't see the "missing semi-colon". I'm about ready to just use the signal to indicate to the GUI that there is something in a shared queue for it to pull off - a less than elegant solution.
For completeness, here are similar posts that I've read but haven't helped me:
stackoverflow: sending-custom-pyqt-signals
stackoverflow: Qt: Not registered qRegisterMetaType()
stackoverflow: QObject (QPlainTextEdit) & Multithreading issues
stackoverflow: QObject::connect: Cannot queue arguments of type 'object' in PySide
TIA stackoverflow community!