问题
If QML is used for GUI and Java for developing API for a linux based device,How to interface QML with Java?
回答1:
One approach for cross platform integration is using web service. I would probably expose my Java code as a RESTful web service (See JAX-RS) and invoke it from QML using XMLHttpRequest.
It's also worth mentioning Java GUI library such as swing / JavaFX has cross platform capability, so it should still run on Linux (and whichever platform runs Java). You might not need to write QML at all
回答2:
Possible approaches I can think of are :
- Qt Jambi
- JNI
[ You have mentioned to tell something other than these ]
Other than this :
Use qml for UI and interface it with C++ using Qt-qml bindings. Then expose these C++ interfaces over some IPC common to both Java and C++ ( For eg. expose something on D-Bus using Qt-Dbus and then call these functionality using Java-DBus code )
来源:https://stackoverflow.com/questions/17185074/how-to-interface-qml-and-java