-
Install Go >= 1.5.1
-
Install Qt 5.5.1
C:\Qt\Qt5.5.1\
or/usr/local/Qt5.5.1/
- https://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-windows-x86-android-5.5.1.exe
- https://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-mac-x64-android-5.5.1.dmg
- https://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x86-android-5.5.1.run
- https://download.qt.io/official_releases/qt/5.5/5.5.1/qt-opensource-linux-x64-android-5.5.1.run
-
Setup the environment
-
Windows
-
Add the directory that contains "gcc.exe" to your PATH
C:\Qt\Qt5.5.1\Tools\mingw492_32\bin
-
-
Mac OS X
- Install Xcode >= 7.0.1
-
Linux
-
Install "g++"
sudo apt-get install g++
-
Install OpenGL dependencies
sudo apt-get install mesa-common-dev
-
-
-
Download the qt binding
go get github.com/therecipe/qt
-
Generate, install and test
github.com/therecipe/qt/setup.bat
(run as admin)or
github.com/therecipe/qt/setup.sh
-
Make sure the binding is working by setting up the Desktop version
-
Install the Android SDK
C:\android\android-sdk\
or/opt/android-sdk/
-
Install the SDK dependencies
C:\android\android-sdk\tools\android.bat
or/opt/android-sdk/tools/android
- Tools
- Android SDK Build-tools (23.0.2)
- Android 6.0 (API 23)
- SDK Platform
- Extras (Windows only)
- Google USB Driver
- Tools
-
Install the Android NDK
C:\android\android-ndk\
or/opt/android-ndk/
-
Install Apache-Ant
C:\android\apache-ant\
or/opt/apache-ant/
-
Install Java SE Development Kit (linux:
/opt/jdk/
) -
Install and test
github.com/therecipe/qt/setup.bat android
(run as admin)or
github.com/therecipe/qt/setup.sh android
-
Create a folder: [GoPath]/src/qtExample
-
Create a file named main.go in this folder
package main
import (
"os"
"github.com/therecipe/qt/widgets"
)
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
var btn = widgets.NewQPushButton2("Hello World", nil)
btn.Resize2(180, 44)
btn.ConnectClicked(func(flag bool) {
widgets.QMessageBox_Information(nil, "OK", "You Clicked me!", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
})
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.Layout().AddWidget(btn)
window.Show()
widgets.QApplication_Exec()
}
3.Open the command line in [GoPath]/src, and run:
qtdeploy build desktop qtExample
4.Wait a minute,and then you will find the executable file here.
[GoPath]/src/qtExample/deploy/{windows|darwin|linux}/qtExample(.exe)