0
votes

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!

1
Does this previously asked question contain the answer you're looking for?sytech
I cannot reproduce this problem using PySide-1.2.4. Presumably, CentOS 6 has a much older version of PySide which is buggy. What exact version are you using?ekhumoro
@Gator_Python: That doesn't help, as it cites using pieces that are PyQt specific and I'm stuck with PySide.PfunnyGuy
@ekhumoro: I don't know. I did a dir(PySide) and there is no version to get, so "Old" is probably the answer. I'll see about updating that. Edit: 'yum' says version 0.4.1. 0.o That just hurts my brain...PfunnyGuy
PySide.QtCore.QSettings.qRegisterMetaType -- Couldn't find any usage examples. But appears to be there. But not sure why you're having a problem.sytech

1 Answers

1
votes

The following is the location of that method, according to the docs. As mentioned in comments, you should upgrade PySide to the latest version as the issue you're having was not reproducible in the current version.

PySide.QtCore.QSettings.qRegisterMetaType