therecipe / qt

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
GNU Lesser General Public License v3.0
10.38k stars 735 forks source link

Felgo binding #968

Open evanw0 opened 4 years ago

evanw0 commented 4 years ago

Hey there,

I see that this tool is tagged with "Felgo" and that there is some basic support already in the code.

It looks like the bindings required in an app for Felgo are quite simple; the only lines that would have to run on the Go side are:

FelgoApplication felgo;
QQmlApplicationEngine engine;
felgo.initialize(&engine);

But since I'm a C++ noob, I'm having a hard time adding these bindings myself, so are there any pointers to what we can do to add bindings for these simple calls?

I think this would be very helpful to many people, and I am interested in contributing some code to enable ios and android builds for Felgo.

therecipe commented 4 years ago

Hey

Yeah, sorry the last time I worked on the Felgo support I only laid the ground work necessary to get it working for projects with mixed C++/Go code bases. But you are right, it would be nice to be able to create and initialize the FelgoApplication from Go as well.

So I looked into this and created bindings for the FelgoApplication and FelgoLiveClient with https://github.com/therecipe/qt/commit/cd53818b8ffcb925d8256eb532061a6ffbdf2f4b

The FelgoLiveClient class is available when using go run/build or qtdeploy -fast and also when exporting QT_FELGO_LIVE=true and then running the plain qtdeploy command (for android or ios builds for example).

I tested this on macOS for the desktop, android-emulator and ios-simulator targets and it seems to work so far. (I couldn't get the LiveClient to connect to the server when testing the android-emulator builds though)

Also thanks for the offer to contribute. There were only a few minor changes needed to get the android and ios targets working, so I hope you don't mind that I went ahead and made the changes necessary to get it working. You could still tremendously help though, by testing the different targets and checking if the LiveClient works as expected.

Btw, I ported some of the felgo example and put them here: https://github.com/therecipe/qt/tree/master/internal/examples/felgo

And yet another thing, there seem to be an issue with some application crashing upon exit which I plan to look into.

evanw0 commented 4 years ago

Thank you so much for this! I will go and test some of the examples on various devices now.

therecipe commented 4 years ago

You are welcome :) Please let me know if you run into any issues.

Btw, I fixed the issue causing the applications to crash upon exit with https://github.com/therecipe/qt/commit/9c4a28ad5becd862bc113970bf29674bc989757d now as well.