Why does calling dynamicCall and querySubObject always get an error in QAxWidget?
-
The development environment is python 3.11 + pyside6. When calling dynamicCall and querySubObject, there is always an error message saying "Unexpected type: (str, int) possible type: (bytes, any)(bytes, sequence)", the code example used is as follows, please see what went wrong? Can you provide the correct call method?
self.ax_widget2.dynamicCall("ActiveDocument.GoTo(int)", 10)
-
@howerl
Maybe it is only a warning as @hskoglund says. But if it needs to be fixed, the message seems to be telling you that you are passing a Pythonstr
for the first argument but it wants a Pythonbytes
type. Try:self.ax_widget2.dynamicCall("ActiveDocument.GoTo(int)".encode('utf-8'), 10)
?
-
@JonB i tried the code, there is no warning again, but error generated when running, the info as follow:
self.ax_widget.dynamicCall("ActiveDocument.GoTo(int)".encode('utf-8'), 10)
ValueError: 'PySide6.QtAxContainer.QAxBase.dynamicCall' called with wrong argument values:
PySide6.QtAxContainer.QAxBase.dynamicCall(b'ActiveDocument.GoTo(int)', 10)
Found signature:
PySide6.QtAxContainer.QAxBase.dynamicCall(bytes, Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any)) -
@howerl said in Why does calling dynamicCall and querySubObject always get an error in QAxWidget?:
PySide6.QtAxContainer.QAxBase.dynamicCall(b'ActiveDocument.GoTo(int)', 10)
The
b'...'
makes it abytes
type, as expected. I do not know why Python saysPySide6.QtAxContainer.QAxBase.dynamicCall(bytes, Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any), Any = Invalid(typing.Any))
is not a matching signature for your call.
If you are able to temporarily install PyQt6 you could try this call there and see whether it is accepted/rejected. In the past there have been cases where PyQt accepts things correctly where PySide does not.
P.S.
I'm not all sure this will work, but you might trydynamicCall(b'ActiveDocument.GoTo(int)', [ 10 ])`
to see if that is accepted.
-
@howerl said in Why does calling dynamicCall and querySubObject always get an error in QAxWidget?:
@JonB I tried it in PyQt6, it looks like right.
Yes, I thought that might be the case. Indicating that what you are trying to do is in principle correct, but PySide has flaws. Did you try the
[ 10 ]
list argument in place of the10
integer argument, in case PySide accepts that?P.S.
You would need a Qt PySide person to look at this. I don't know whether it's appropriate, but I'm putting a shout-out to @CristianMaureira here, he seemed to answer a question recently implying he is a Qt in-house PySide development type? -