3

I'm trying to port a code from PyQt5 to PySide2. At a certain point, I'm using:

QMetaObject.invokeMethod(dialog, "my_function", Qt.QueuedConnection, QGenericArgument.Q_ARG(str, filepath))

Nevertheless, Q_ARG is not into QGenericArgument in PySide2. In fact, I have not been able to locate it at all, despite it is described in the documentation as the macro to be used instead of QGenericArgument.

Plan B: I tried using QGenericArgument directly, even while documentation discourages to do it. Therefore I tried these:

QMetaObject.invokeMethod(dialog, "my_function", Qt.QueuedConnection, QGenericArgument(str, filepath))

QMetaObject.invokeMethod(dialog, "my_function", Qt.QueuedConnection, QGenericArgument('str', filepath))

QMetaObject.invokeMethod(dialog, "my_function", Qt.QueuedConnection, QGenericArgument('QString', filepath))

In all of the cases, the error has been the same:

ERROR: 'PySide2.QtCore.QGenericArgument' called with wrong argument types:
PySide2.QtCore.QGenericArgument(str, str)
Supported signatures:
PySide2.QtCore.QGenericArgument(PySide2.QtCore.QGenericArgument)
PySide2.QtCore.QGenericArgument(bytes = nullptr, void = nullptr)

So it seems that I must use pointers here, but don't know how to do that. Also, I have not found any example of invokeMethod for PySide2.

Any idea?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
  • Possible duplicate of [QMetaObject::invokeMethod doesn't find methods with parameters](https://stackoverflow.com/questions/23538904/qmetaobjectinvokemethod-doesnt-find-methods-with-parameters) – eyllanesc Nov 14 '18 at 11:43
  • unfortunately PySide2 inherits the same limitations of PySide – eyllanesc Nov 14 '18 at 11:43
  • So, no news in last years for this issue? In that question the OP is using 'QString' in GenericArgument, and str in the slot (just as I already tried with no success). Any workaround? – Roman Rdgz Nov 14 '18 at 15:26
  • As they point out in the answer that is a bug, it does not matter if it is QString or str, which still remains in PySide2 and unfortunately there is no workaround – eyllanesc Nov 14 '18 at 15:35

0 Answers0