thp / pyotherside

Python Bindings for Qt 5 and Qt 6. Allows you to access a CPython 3 interpreter directly from your Qt QML user interface code.
https://thp.io/2011/pyotherside/
Other
364 stars 49 forks source link

Calling a QObject signal from python doesn't work! #98

Closed NikkSaan closed 5 years ago

NikkSaan commented 5 years ago

Calling a regular method works, calling a signal doesn't. It prints: RuntimeError: QObject method call failed

Is this normal?

thp commented 5 years ago

Can you post a Short, Self Contained, Correct Example that demonstrates the issue? Also, in Qt when calling signals, AFAIR it just "emits" the signal, so you have to connect something to the signal for it to work. In QML, see this: http://doc.qt.io/qt-5/qtqml-syntax-signals.html#connecting-signals-to-methods-and-signals

NikkSaan commented 5 years ago

I'm running "test.qml" in a slightly modified "qmlscene"-kind of a program, more suited for my embedded platform. But the program just adds Pyotherside's import path to the QML Engine, and sets some QPA parameters. Also, Pyotherside is compiled against musl-libc.

Here is the test I ran, I can't make it more self-contained than that. I also tried using the "onCallSignal" handler, it still wouldn't work.

test.qml : https://pastebin.com/KuQFRbdf TestModule.py : https://pastebin.com/GjyJp7TP

Result : https://pastebin.com/B3kBKgat

I'll assume it's a problem with my setup, and do without calling signals. I want to continue working on my project. I really just wanted to know If calling a signal was supported.

Sorry, I have to use Pastebin.

thp commented 5 years ago

Thanks for that, the QMetaMethod::invoke() failed on the signal, because we tried to do a direct connection, and that apparently doesn't work with signals. As signals don't have any return value, instead we use Qt::AutoConnection for signals now, and only return true or false depending on whether it worked or now.

NikkSaan commented 5 years ago

Wow, you're welcome! I didn't expect that this would result in a bug fix, and so quickly. Thank you!!!