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.46k stars 745 forks source link

crazy idea to use gomobiel with QT #268

Closed joeblew99 closed 7 years ago

joeblew99 commented 7 years ago

I have been messing around with mobile and using services on them and notifications and other sort of things.

At the moment doing this with QT is not really possible. Yell if you disagree. But before i started using QT and golang i used gomobile.

So i think that we can use the gomobile reverse code. https://godoc.org/golang.org/x/mobile/cmd/gobind#hdr-Reverse_bindings

You can target objective c and java and create a golang binding. This is pretty cool because there is lots out there that we can use.

For example i need an event bus on android and ios. Cant do that with QT really. But here is one that is used by a tons of android devs that i can tap into https://github.com/greenrobot/EventBus

I think this is the best of gomobile and QT mix up :)

joeblew99 commented 7 years ago

https://www.slideshare.net/mobile/takuyaueda967/mobile-apps-by-pure-go-with-reverse-binding

therecipe commented 7 years ago

Hey

At the moment doing this with QT is not really possible. Yell if you disagree.

I haven't tried it myself, but there is a way to create a service: https://doc.qt.io/qt-5/androidservices.html

and there are also a few helper functions: http://doc.qt.io/qt-5/qtandroid.html#androidService https://github.com/therecipe/qt/blob/master/androidextras/androidextras_android.go#L3342-L3346

So i think that we can use the gomobile reverse code.

Yeah, I'm aware of gomobile, but I never really used it. Depending on what you need, the "androidextras" module might be good enough. It can be used to call java function from go, but you can also call go from java with a little manual labor.

This example here shows you how to call java from: qml -> (c) -> go -> (c) -> java https://github.com/therecipe/qt/tree/master/internal/examples/androidextras/notification

and this example shows you how to create a java object in go and then let the java object callback into go code: https://github.com/therecipe/qt/tree/master/internal/examples/androidextras/jni

But if you want to target both, android and iOS then gomobile is probably the better option.

joeblew99 commented 7 years ago

@therecipe thanks for the links and review. Really appreciate the feedback.

i see your point.

I guess my main wants are:

The other thing is that it solves the lack of webviews working on IOS maybe. Here is a simple example for Android webview. Its not complete but shows the ease. https://github.com/microo8/meh/blob/master/mobile/test1/test1.go

joeblew99 commented 7 years ago

I will close this. I played around with this idea today but it did not work out well.

therecipe commented 7 years ago

no problem :)

ios: not sure is macextras provides this ? Seems to want to work with a Toolbar, so not ios ?

Sadly no, I think there are no iOS helper functions afaik. As it's relatively simple to work with Obj-C++ (from C++) I guess.

Qt wants me to use remote objects which if i recall is maybe in QT 5.9.

Yeah, I think that would be the most convenient solution for your problem. If we are lucky the beta will be released in the current or in the next week. https://wiki.qt.io/Qt_5.9_Release