swx
swx

Reputation: 65

Q_ARG Missing from PySide - How to proceed?

I've hit a problem working with PySide [Python 3.3.3 / PySide 1.2.1] and invokeMethod - it seems PySide doesn't have the Q_ARG macro baked in.

QtCore.QMetaObject.invokeMethod(self.worker, '_reader_run_mfoc_dummy',
                                             QtCore.Qt.QueuedConnection,
                                             QtCore.Q_ARG(str, self.get_keys_filename()),
                                             QtCore.Q_ARG(str, self.get_dump_filename()))

returns:

QtCore.Q_ARG(str, self.get_keys_filename()),
AttributeError: 'module' object has no attribute 'Q_ARG'

Despite warnings from the Documents not to do so, even if I try to pass a generic argument, it fails (but for a different reason):

QtCore.QMetaObject.invokeMethod(self.worker, '_reader_run_mfoc_dummy',
                                             QtCore.Qt.QueuedConnection,
                                             QtCore.QGenericArgument("str",self.get_keys_filename()),
                                             QtCore.QGenericArgument("str",self.get_dump_filename()))

QMetaObject::invokeMethod: No such method Worker::_reader_run_mfoc_dummy(str,str)

Despite my Slot / Method signature being:

@QtCore.Slot(str, str)
def _reader_run_mfoc_dummy(self, keys_filename, dump_filename):

Does anyone have a suggestion on how to get around this problem? I'm unsure why it fails to find the target method..

Upvotes: 2

Views: 1371

Answers (1)

NoDataDumpNoContribution
NoDataDumpNoContribution

Reputation: 10864

It seems to be a bug in PySide. invokeMethod doesn't work currently with arguments in PySide. Use QtCore.QTimer.singleshot(..) or send an Event or emit a Signal instead.

See my question QMetaObject::invokeMethod doesn't find methods with parameters here. Also you should use QString instead of str in QGenericArgument but then Python will crash.

Upvotes: 2

Related Questions