HomeBrew 不支持 iOS/Android
go的版本为go1.9.7,低版本1.8,缺少math/bits包
1. 安装HomeBrew 和 qt
# 先安装 HomeBrew,并且 export QT_HOMEBREW=true brew install qt5 //安装 Qt
2. 设置环境变量
找到qt的安装目录,默认在 /usr/local/Cellar/qt/5.11.1 设置环境变量: QT_DIR = /usr/local/Cellar/qt/5.11.1
3. 克隆qt
go get -u -v github.com/therecipe/qt/cmd/...
4. 安装qtsetup、qtdeploy、qtminimal、 qtmoc、 qtrcc,安装前查看echo $GOBIN目录。默认安装在此目录。
1. github.com/therecipe/qt/cmd 执行安装命令 go install -x qtsetup/main.go //安装qt的各种包 go install -x qtdeploy/main.go // 发布qt的程序 go install -x qtminimal/main.go // 减少编译文件大小 go install -x qtmoc/main.go //Qt的moc包。 go install -x qtrcc/main.go //Qt的rcc包。
具体工具的使用教程: https://github.com/therecipe/qt/wiki/Available-Tools
5. 测试
#获取测试代码 go get -d -v github.com/therecipe/examples/... cd $GOPATH/src/github.com/therecipe/examples qtdeploy test desktop ./basic/widgets //执行
测试相关的教程:https://github.com/therecipe/qt/wiki/Getting-Started
效果如下:
6. 测试感想
测试了几个案例,编译的过程有点慢。可能是文件太多了,调用的东西也多。
需要点C++的基础,可能上手更快。