Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC - experience from user migrating from QtScript (Qt5) to pythonqt (Qt6) #226

Open
JulienMaille opened this issue Jul 2, 2024 · 3 comments
Labels
question Further information is requested

Comments

@JulienMaille
Copy link

Hello and thanks a lot for this incredible work.
I have a question rather than an issue: I'm desperately looking for a solution to migrate from Qt5 to Qt6 without losing the scriptability of my application. I rely a lot on qtscriptgenerator classes and was using tricks like exposing the a top widget of my app to QtScript and then the "auto-discoverability" of all its widgets (and theit slots/properties), which would allow the scripter to insert his own script-defined widgets, hide or move existing ones, etc.
Is this something that I could to with pythonqt?
Thanks in advance.

PS: until now I had found https://github.com/qcad/qtjsapi and PySide/Shiboken, how is pythonqt different from the latter (except the setup seems to be much simpler)

@iltommi
Copy link

iltommi commented Jul 2, 2024

QJSEngine is still there in qt6 (in Qml qt6 module) if you want to stick to ecma javascript

#include <QJSEngine>
[...]
QJSEngine = my_eng;
my_eng.globalObject().setProperty("myobj", my_eng.newQObject(myobj));
QJSValue retval = my_eng.evaluate("myobj.dosomething()");

@JulienMaille
Copy link
Author

QJSEngine is still there in qt6 (in Qml qt6 module) if you want to stick to ecma javascript

Sure but you can't benefit from QtScriptGenerator, can you?

@usiems
Copy link
Contributor

usiems commented Jul 3, 2024

Yes, you can do the things you requested with PythonQt: The Qt API is wrapped for the most part, and you can derive from existing Qt classes in Python.

I don't really know PySide/Shiboken, so I couldn't tell you all the actual differences. One thing that I know of, which makes PythonQt slightly incompatible with PySide, is that Qt proprties take precedence over methods with the same name in PythonQt. Also super() doesn't work for Qt classes in PythonQt, you have to use the class name of the super class.

@mrbean-bremen mrbean-bremen added the question Further information is requested label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants