cutego/README.md

593 lines
26 KiB
Markdown
Raw Normal View History

2016-10-20 19:38:53 +03:00
[![GoDoc](https://godoc.org/github.com/therecipe/qt?status.svg)](https://godoc.org/github.com/therecipe/qt)
[![GoCover](http://gocover.io/_badge/github.com/therecipe/qt)](http://gocover.io/github.com/therecipe/qt)
[![GoReportCard](https://goreportcard.com/badge/github.com/therecipe/qt)](https://goreportcard.com/report/github.com/therecipe/qt)
[![TravisCI](https://travis-ci.org/therecipe/qt.svg?branch=master)](https://travis-ci.org/therecipe/qt)
[![AppveyorCI](https://ci.appveyor.com/api/projects/status/github/therecipe/qt?branch=master&svg=true)](https://ci.appveyor.com/project/therecipe/qt)
[![SemaphoreCI](https://semaphoreci.com/api/v1/therecipe/qt/branches/master/shields_badge.svg)](https://semaphoreci.com/therecipe/qt)
[![CircleCI](https://circleci.com/gh/therecipe/qt/tree/master.svg?style=svg)](https://circleci.com/gh/therecipe/qt/tree/master)
## Overview
[Qt](https://en.wikipedia.org/wiki/Qt_(software)) is a cross-platform application framework.
[Go](https://en.wikipedia.org/wiki/Go_(programming_language)) (often referred to as golang) is a free and open source programming language created at Google.
This binding aims to make it as simple as possible to write applications for all operating systems supported by Qt in Go.
The project is pretty much a WIP and **not** recommended to be used in production yet.
2016-10-20 19:38:53 +03:00
However it should already contain everything you need to build fully featured Qt applications in Go.
2016-10-20 19:38:53 +03:00
2016-10-30 00:28:13 +03:00
[Screenshots of the Line Edits example](internal/screenshots)
## Installation
#### Environmental variables
2016-05-15 23:07:05 +03:00
2016-11-12 18:06:57 +03:00
If you define environmental variables during the installation export them system wide, as they are needed not only during the installation but also later.
2016-05-15 23:07:05 +03:00
2016-11-12 18:06:57 +03:00
Add the environmental variables into your `$HOME/.bash_profile` or `$HOME/.profile` on macOS or Linux.
2016-05-15 23:07:05 +03:00
2016-10-28 05:00:58 +03:00
Or if you are on Windows simply use the advanced system settings.
2016-06-11 02:50:53 +03:00
And you might also need to set `CGO_ENABLED=1` and `GOARCH=386` if you want to use `go build` on windows.
#### Docker Images
2016-06-11 02:50:53 +03:00
You can also use Docker images from [hub.docker](https://hub.docker.com/r/therecipe/qt/).
To cross compile to Windows, Linux and Android.
**You will still need to install the desktop version for your host system first!**
2017-01-16 20:10:20 +03:00
**But if you want to use the images only for CI, then you probably don't need to install the binding or Qt on the host. Simply installing and using `qtdeploy` should be enough.**
#### Command line debugging
2014-12-02 23:51:56 +03:00
You can export `QT_DEBUG=true` before "qtdeploying" your application to enable printing of the current function name at runtime.
2016-11-16 21:02:52 +03:00
#### Speedup your development
Instead of using `qtdeploy` during development, you might want to use `qtrcc`, `qtmoc`, `qtminimal` manually with `go build/run -tags=minimal ...`
In general `qtminimal` should always be called after the use of the optional use of `qtrcc` and `qtmoc`.
`qtrcc` is used to bundle your `project/qml` folder so you can access the files within by using the `qrc` prefix, like this `qrc:///qml/somefile` from various Qt functions.
2017-01-16 20:10:20 +03:00
`qtmoc` is used to subclass core.QObject based classes and to add your own signals/slots/properties as shown in some examples.
2016-11-16 21:02:52 +03:00
`qtminimal` is used to create a small subset of the binding tailored to your code to reduce the binary size. (Use the `-tags=minimal` flag to make use of it)
If you use the STUB version, you are forced to use `qtminimal` otherwise it's optional like `qtrcc` and `qtmoc`.
#### Update and upgrade
If you want to update the binding, you can simply use `qtsetup update`.
This will only update the `qt*` tools and saves you from re-running the full `qtsetup`.
It should be also sufficient in most cases.
If you however prefer a full upgrade then use `qtsetup upgrade`.
This will remove all leftovers first, and then update the binding to the latest version.
You should run `qtsetup` after each upgrade.
#### Instructions
2016-10-20 19:38:53 +03:00
* Desktop (click to expand)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
<details>
<summary>Windows</summary>
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
1. Install Go >= 1.7.1 and setup a proper [**GOPATH**](https://golang.org/doc/code.html#GOPATH)
2014-12-02 23:51:56 +03:00
2017-02-27 23:33:52 +03:00
* https://golang.org/doc/install?download=go1.8.windows-amd64.msi
2. Install Qt 5.8.0 (with android support)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
* Install the official prebuilt package; you can also define a custom location with **QT_DIR**.
* https://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-windows-x86-android-5.8.0.exe
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
or (without android support)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
* Install the Qt-dev package with [MSYS2](http://msys2.github.io) and define **QT_MSYS2=true** or define a custom Qt location with **QT_MSYS2_DIR** (usually: C:\msys32\ or C:\msys64\);
* `pacman -Syyu`
* if you want to deploy 32-bit applications `pacman -S mingw-w64-i686-qt-creator mingw-w64-i686-qt5`
* if you want to deploy 64-bit applications `pacman -S mingw-w64-x86_64-qt-creator mingw-w64-x86_64-qt5`
* `pacman -Scc`
2016-11-05 22:49:45 +03:00
2017-02-01 11:26:56 +03:00
3. Add the directory that contains **gcc** and **g++** to your **PATH** (not needed with MSYS2)
2016-11-05 22:49:45 +03:00
* `C:\Qt\Qt5.8.0\Tools\mingw530_32\bin`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
4. Download the binding
* `go get -u -v github.com/therecipe/qt/cmd/...`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
5. Generate, install and test (20 min) (MSYS2: run within the MSYS2 MinGW 32-bit or MSYS2 MinGW 64-bit shell)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
* `%GOPATH%\bin\qtsetup`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
6. Create your first [application](#example)
2015-11-09 20:23:42 +03:00
2017-02-01 11:26:56 +03:00
7. Deploy applications with `%GOPATH%\bin\qtdeploy build desktop path\to\your\project` (MSYS2: run within the MSYS2 MinGW 32-bit or MSYS2 MinGW 64-bit shell)
</details>
2015-11-09 20:23:42 +03:00
2017-02-01 11:26:56 +03:00
<details>
<summary>macOS</summary>
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
1. Install Go >= 1.7.1 and setup a proper [**GOPATH**](https://golang.org/doc/code.html#GOPATH)
2017-02-27 23:33:52 +03:00
* https://golang.org/doc/install?download=go1.8.darwin-amd64.pkg
2. Install Qt 5.8.0 (with android/iOS support)
2017-02-01 11:26:56 +03:00
* Install the official prebuilt package; you can also define a custom location with **QT_DIR**.
* without iOS https://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-mac-x64-android-5.8.0.dmg
* with iOS https://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-mac-x64-android-ios-5.8.0.dmg
2017-02-01 11:26:56 +03:00
or (without android/iOS support)
2017-02-01 11:26:56 +03:00
* Install the Qt-dev package with Homebrew and define **QT_HOMEBREW=true** or define a custom Qt location with **QT_DIR** (usually: /usr/local/opt/qt5/); if you want to link against homebrews Qt libs (**experimental**)
* `brew install qt5`
2017-02-01 11:26:56 +03:00
3. Install **Xcode** >= 7.2.0; you can also define a custom location with **XCODE_DIR**
2017-02-01 11:26:56 +03:00
* https://itunes.apple.com/us/app/xcode/id497799835
2017-02-01 11:26:56 +03:00
4. Download the binding
2017-02-01 11:26:56 +03:00
* `go get -u -v github.com/therecipe/qt/cmd/...`
2017-02-01 11:26:56 +03:00
5. Generate, install and test (20 min)
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup`
2017-02-01 11:26:56 +03:00
6. Create your first [application](#example)
2017-02-01 11:26:56 +03:00
7. Deploy applications with `$GOPATH/bin/qtdeploy build desktop path/to/your/project`
</details>
2017-02-01 11:26:56 +03:00
<details>
<summary>Linux</summary>
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
1. Install Go >= 1.7.1 and setup a proper [**GOPATH**](https://golang.org/doc/code.html#GOPATH)
2015-11-09 20:23:42 +03:00
2017-02-27 23:33:52 +03:00
* https://golang.org/doc/install?download=go1.8.linux-amd64.tar.gz
2. Install Qt 5.8.0 (with android support)
2017-02-01 11:26:56 +03:00
* Install the official prebuilt package; you can also define a custom location with **QT_DIR**.
* https://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-linux-x64-android-5.8.0.run
2017-02-01 11:26:56 +03:00
or (without android support)
2017-02-01 11:26:56 +03:00
* Install the Qt-dev package with your system package manager; if you want to link against your system Qt libs (**experimental**)
* add **export QT_PKG_CONFIG=true** to your .profile or .bash_profile
* if needed you can also define custom locations for the misc and doc dir with **QT_MISC_DIR** and/or **QT_DOC_DIR**
* and you may want to define a custom pkg-config search path with **PKG_CONFIG_PATH**, if the default path points to old Qt pkg-config files
2017-02-01 11:26:56 +03:00
3. Install **g++** >= 5 and **OpenGL** dependencies
2016-10-14 20:06:35 +03:00
2017-02-01 11:26:56 +03:00
* Debian/Ubuntu (apt-get)
* `sudo apt-get -y install build-essential libgl1-mesa-dev`
2016-10-14 20:06:35 +03:00
2017-02-01 11:26:56 +03:00
* Fedora/RHEL/CentOS (yum)
* `sudo yum -y groupinstall "C Development Tools and Libraries"`
* `sudo yum -y install mesa-libGL-devel`
2017-02-01 11:26:56 +03:00
* openSUSE (zypper)
* `sudo zypper -n install -t pattern devel_basis`
2017-02-01 11:26:56 +03:00
4. Download the binding
2017-02-01 11:26:56 +03:00
* `go get -u -v github.com/therecipe/qt/cmd/...`
2017-02-01 11:26:56 +03:00
5. Generate, install and test (20 min)
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup`
2017-02-01 11:26:56 +03:00
6. Create your first [application](#example)
2017-02-01 11:26:56 +03:00
7. Deploy applications with `$GOPATH/bin/qtdeploy build desktop path/to/your/project` (use the *.sh file to start your application)
2017-02-01 11:26:56 +03:00
#### **Optional:** Cross compile for Windows on Debian/Ubuntu (**experimental**)
2017-02-01 11:26:56 +03:00
1. Install Wine
2017-02-01 11:26:56 +03:00
* `sudo apt-get -y install wine`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
2. Install MXE (M cross environment)
* `echo "deb http://pkg.mxe.cc/repos/apt/debian jessie main" | sudo tee --append /etc/apt/sources.list.d/mxeapt.list > /dev/null`
2017-02-01 11:26:56 +03:00
* `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D43A795B73B16ABE9643FE1AFD8FFF16DB45C6AB`
2017-02-01 11:26:56 +03:00
* `sudo apt-get update`
* if you want to deploy 32-bit applications `sudo apt-get -y -qq install mxe-i686-w64-mingw32.shared-qt3d mxe-i686-w64-mingw32.shared-qtactiveqt mxe-i686-w64-mingw32.shared-qtbase mxe-i686-w64-mingw32.shared-qtcanvas3d mxe-i686-w64-mingw32.shared-qtcharts mxe-i686-w64-mingw32.shared-qtconnectivity mxe-i686-w64-mingw32.shared-qtdatavis3d mxe-i686-w64-mingw32.shared-qtdeclarative mxe-i686-w64-mingw32.shared-qtgamepad mxe-i686-w64-mingw32.shared-qtgraphicaleffects mxe-i686-w64-mingw32.shared-qtimageformats mxe-i686-w64-mingw32.shared-qtlocation mxe-i686-w64-mingw32.shared-qtmultimedia mxe-i686-w64-mingw32.shared-qtofficeopenxml mxe-i686-w64-mingw32.shared-qtpurchasing mxe-i686-w64-mingw32.shared-qtquickcontrols mxe-i686-w64-mingw32.shared-qtquickcontrols2 mxe-i686-w64-mingw32.shared-qtscript mxe-i686-w64-mingw32.shared-qtscxml mxe-i686-w64-mingw32.shared-qtsensors mxe-i686-w64-mingw32.shared-qtserialbus mxe-i686-w64-mingw32.shared-qtserialport mxe-i686-w64-mingw32.shared-qtservice mxe-i686-w64-mingw32.shared-qtsvg mxe-i686-w64-mingw32.shared-qtsystems mxe-i686-w64-mingw32.shared-qttools mxe-i686-w64-mingw32.shared-qttranslations mxe-i686-w64-mingw32.shared-qtvirtualkeyboard mxe-i686-w64-mingw32.shared-qtwebchannel mxe-i686-w64-mingw32.shared-qtwebkit mxe-i686-w64-mingw32.shared-qtwebsockets mxe-i686-w64-mingw32.shared-qtwinextras mxe-i686-w64-mingw32.shared-qtxlsxwriter mxe-i686-w64-mingw32.shared-qtxmlpatterns`
* if you want to deploy 64-bit applications `sudo apt-get -y -qq install mxe-x86-64-w64-mingw32.shared-qt3d mxe-x86-64-w64-mingw32.shared-qtactiveqt mxe-x86-64-w64-mingw32.shared-qtbase mxe-x86-64-w64-mingw32.shared-qtcanvas3d mxe-x86-64-w64-mingw32.shared-qtcharts mxe-x86-64-w64-mingw32.shared-qtconnectivity mxe-x86-64-w64-mingw32.shared-qtdatavis3d mxe-x86-64-w64-mingw32.shared-qtdeclarative mxe-x86-64-w64-mingw32.shared-qtgamepad mxe-x86-64-w64-mingw32.shared-qtgraphicaleffects mxe-x86-64-w64-mingw32.shared-qtimageformats mxe-x86-64-w64-mingw32.shared-qtlocation mxe-x86-64-w64-mingw32.shared-qtmultimedia mxe-x86-64-w64-mingw32.shared-qtofficeopenxml mxe-x86-64-w64-mingw32.shared-qtpurchasing mxe-x86-64-w64-mingw32.shared-qtquickcontrols mxe-x86-64-w64-mingw32.shared-qtquickcontrols2 mxe-x86-64-w64-mingw32.shared-qtscript mxe-x86-64-w64-mingw32.shared-qtscxml mxe-x86-64-w64-mingw32.shared-qtsensors mxe-x86-64-w64-mingw32.shared-qtserialbus mxe-x86-64-w64-mingw32.shared-qtserialport mxe-x86-64-w64-mingw32.shared-qtservice mxe-x86-64-w64-mingw32.shared-qtsvg mxe-x86-64-w64-mingw32.shared-qtsystems mxe-x86-64-w64-mingw32.shared-qttools mxe-x86-64-w64-mingw32.shared-qttranslations mxe-x86-64-w64-mingw32.shared-qtvirtualkeyboard mxe-x86-64-w64-mingw32.shared-qtwebchannel mxe-x86-64-w64-mingw32.shared-qtwebkit mxe-x86-64-w64-mingw32.shared-qtwebsockets mxe-x86-64-w64-mingw32.shared-qtwinextras mxe-x86-64-w64-mingw32.shared-qtxlsxwriter mxe-x86-64-w64-mingw32.shared-qtxmlpatterns`
2017-02-01 11:26:56 +03:00
3. Export `QT_MXE_ARCH=386` to deploy 32-bit applications or `QT_MXE_ARCH=amd64` to deploy 64-bit applications.
2017-02-01 11:26:56 +03:00
4. Generate, install and test (20 min)
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup windows`
2017-02-01 11:26:56 +03:00
5. Deploy applications with `$GOPATH/bin/qtdeploy build windows path/to/your/project`
</details>
2017-02-01 11:26:56 +03:00
* Mobile
2017-02-01 11:26:56 +03:00
<details>
<summary>Android</summary>
2017-02-01 11:26:56 +03:00
1. Install the desktop version for Windows, macOS or Linux
2017-02-01 11:26:56 +03:00
2. Unzip the Android SDK in `C:\android-sdk-windows\` or `$HOME/android-sdk-macosx/` or `$HOME/android-sdk-linux/`; you can also define a custom location with **ANDROID_SDK_DIR**
2017-02-03 17:49:26 +03:00
* https://dl.google.com/android/repository/tools_r25.2.5-windows.zip
* https://dl.google.com/android/repository/tools_r25.2.5-macosx.zip
* https://dl.google.com/android/repository/tools_r25.2.5-linux.zip
2017-02-01 11:26:56 +03:00
3. Install the SDK dependencies with `C:\android-sdk-windows\tools\android.bat` or `$HOME/android-sdk-{ macosx | linux }/tools/android`
* Tools
* Android SDK Build-tools (25.0.2)
* Android 7.1.1 (API 25)
* SDK Platform
* Extras (Windows only)
* Google USB Driver
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
4. Unzip the Android NDK in `C:\` or `$HOME`; you can also define a custom location with **ANDROID_NDK_DIR**
* https://dl.google.com/android/repository/android-ndk-r13b-windows-x86_64.zip
* https://dl.google.com/android/repository/android-ndk-r13b-darwin-x86_64.zip
* https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
5. Install Java SE Development Kit >= 8 (Linux: install in `$HOME/jdk/`); you can also define a custom location with **JDK_DIR**
* https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
6. Install and test (20 min)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
* `%GOPATH%\bin\qtsetup android`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
or
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup android`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
7. Create your first [application](#example)
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
8. Deploy applications with `[GOPATH]/bin/qtdeploy build android path/to/your/project`
2014-12-02 23:51:56 +03:00
2017-02-01 11:26:56 +03:00
9. [More info for permissions, app icon, java native interface etc](internal/docs/android.md)
</details>
2017-02-01 11:26:56 +03:00
<details>
2017-02-01 14:05:04 +03:00
<summary>iOS</summary>
2017-02-01 11:26:56 +03:00
1. Install the desktop version for macOS
2017-02-01 11:26:56 +03:00
2. Install and test (20 min)
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup ios && $GOPATH/bin/qtsetup ios-simulator`
2016-05-15 23:07:05 +03:00
2017-02-01 11:26:56 +03:00
3. Create your first [application](#example)
2016-05-15 23:07:05 +03:00
2017-02-01 11:26:56 +03:00
4. Deploy applications with `$GOPATH/bin/qtdeploy build ios path/to/your/project` or `$GOPATH/bin/qtdeploy build ios-simulator path/to/your/project`
</details>
2016-05-15 23:07:05 +03:00
2017-02-01 11:26:56 +03:00
<details>
<summary>Sailfish OS</summary>
2016-05-15 23:07:05 +03:00
1. Install the desktop version for Windows, macOS or Linux (**Qt <= 5.7.x required**)
2016-05-15 23:07:05 +03:00
2017-02-01 11:26:56 +03:00
2. Install VirtualBox; you can also define a custom location with **VIRTUALBOX_DIR**
2017-02-03 17:49:26 +03:00
* http://download.virtualbox.org/virtualbox/5.1.14/VirtualBox-5.1.14-112924-Win.exe
* http://download.virtualbox.org/virtualbox/5.1.14/VirtualBox-5.1.14-112924-OSX.dmg
* http://download.virtualbox.org/virtualbox/5.1.14/VirtualBox-5.1.14-112924-Linux_amd64.run
2017-02-01 11:26:56 +03:00
3. Install the Sailfish OS SDK; you can also define a custom location with **SAILFISH_DIR**
* https://releases.sailfishos.org/sdk/installers/1611/SailfishOSSDK-Beta-1611-Qt5-windows-offline.exe
* https://releases.sailfishos.org/sdk/installers/1611/SailfishOSSDK-Beta-1611-Qt5-mac-offline.dmg
* https://releases.sailfishos.org/sdk/installers/1611/SailfishOSSDK-Beta-1611-Qt5-linux-64-offline.run
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
4. Install and test (20 min)
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
* `%GOPATH%\bin\qtsetup sailfish && %GOPATH%\bin\qtsetup sailfish-emulator`
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
or
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup sailfish && $GOPATH/bin/qtsetup sailfish-emulator`
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
5. Create your first [application](#example)
2017-02-01 11:26:56 +03:00
6. Deploy applications with `[GOPATH]/bin/qtdeploy build sailfish path/to/your/project` or `[GOPATH]/bin/qtdeploy build sailfish-emulator path/to/your/project`
</details>
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
* Embedded
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
<details>
<summary>Raspberry Pi</summary>
2016-06-11 02:50:53 +03:00
2017-02-01 11:26:56 +03:00
1. Install the desktop version for Linux
2017-02-01 11:26:56 +03:00
2. Create a folder `$HOME/raspi`
2017-02-01 11:26:56 +03:00
* `mkdir $HOME/raspi`
2017-02-01 11:26:56 +03:00
3. Download and unpack the Qt source
* `cd $HOME/raspi && wget https://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.tar.gz`
* `tar -xzf qt-everywhere-opensource-src-5.8.0.tar.gz qt-everywhere-opensource-src-5.8.0`
2017-02-01 11:26:56 +03:00
4. Patch Qt Source
2015-11-19 21:29:30 +03:00
* `cd $HOME/raspi/qt-everywhere-opensource-src-5.8.0/qtbase && sed -i 's/c++1z/c++11/' ./mkspecs/devices/linux-rpi3-g++/qmake.conf`
* `cd $HOME/raspi/qt-everywhere-opensource-src-5.8.0/qtwayland && wget https://github.com/qtproject/qtwayland/commit/75294be3.patch && patch -p1 -i 75294be3.patch`
2017-02-01 11:26:56 +03:00
5. Download the cross compiler; you can also define a custom location with **RPI_TOOLS_DIR** (but then you might need to manually change commands from here on during the setup)
2017-02-01 11:26:56 +03:00
* `cd $HOME/raspi && git clone --depth 1 https://github.com/raspberrypi/tools.git`
2017-02-01 11:26:56 +03:00
6. Get dependencies and install Arch Linux on your SD card
2017-02-01 11:26:56 +03:00
* `sudo apt-get -y install bsdtar libwayland-dev flex bison gperf python`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 1
* https://archlinuxarm.org/platforms/armv6/raspberry-pi
2017-02-01 11:26:56 +03:00
* Raspberry Pi 2
* https://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2
2017-02-01 11:26:56 +03:00
* Raspberry Pi 3
* https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
2017-02-01 11:26:56 +03:00
7. Start your Raspberry Pi
2017-02-01 11:26:56 +03:00
8. Enable root login over ssh
2017-02-01 11:26:56 +03:00
* `export RASPI_IP=192.168.XXX.XXX` (replace XXX.XXX with the valid ip ending)
2017-02-01 11:26:56 +03:00
* `ssh alarm@$RASPI_IP` (password: alarm)
2017-02-01 11:26:56 +03:00
* `su` (password: root)
2017-02-01 11:26:56 +03:00
* `sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config && sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config && systemctl restart sshd.service`
2017-02-01 11:26:56 +03:00
9. Update and install dependencies (5 min)
2017-02-01 11:26:56 +03:00
* `pacman -Syyu`
2017-02-01 11:26:56 +03:00
* `pacman -S fontconfig icu libinput libjpeg-turbo libproxy libsm libxi libxkbcommon-x11 libxrender tslib xcb-util-image xcb-util-keysyms xcb-util-wm freetds gtk3 libfbclient libmariadbclient mtdev postgresql-libs unixodbc assimp bluez-libs sdl2 jasper libmng libwebp gst-plugins-base-libs libpulse openal gst-plugins-bad hunspell libxcomposite wayland gst-plugins-base libxslt gst-plugins-good ffmpeg jsoncpp libevent libsrtp libvpx libxcursor libxrandr libxss libxtst nss opus protobuf snappy xcb-util xcb-util-cursor xcb-util-renderutil xcb-util-xrm libxfixes libxshmfence libxext libx11 libxcb libice weston ttf-freefont lxde gamin xorg-server xorg-xinit xorg-server-utils mesa xf86-video-fbdev xf86-video-vesa xorg-server-xwayland xf86-input-libinput gst-plugins-ugly sqlite2 cups xorg-server-devel rsync`
2017-02-01 11:26:56 +03:00
* `pacman -Scc`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 1
* `sed -i 's/gpu_mem=64/gpu_mem=128/' /boot/config.txt`
* `echo "exec startlxde" >> $HOME/.xinitrc && mkdir $HOME/.config/ && echo -e "[core]\nbackend=fbdev-backend.so\nmodules=xwayland.so" >> $HOME/.config/weston.ini`
2017-02-01 11:26:56 +03:00
**experimental**: enable OpenGL under X; will break most applications
* `echo "dtoverlay=vc4-kms-v3d,cma-128" >> /boot/config.txt && sed -i 's/fbdev-backend/drm-backend/' $HOME/.config/weston.ini`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 2 or 3
* `sed -i 's/gpu_mem=64/gpu_mem=256/' /boot/config.txt`
* `echo "exec startlxde" >> $HOME/.xinitrc && mkdir $HOME/.config/ && echo -e "[core]\nbackend=fbdev-backend.so\nmodules=xwayland.so" >> $HOME/.config/weston.ini`
2017-01-16 20:10:20 +03:00
2017-02-01 11:26:56 +03:00
**experimental**: enable OpenGL under X; will break most applications
* `echo "dtoverlay=vc4-kms-v3d,cma-256" >> /boot/config.txt && sed -i 's/fbdev-backend/drm-backend/' $HOME/.config/weston.ini`
2017-02-01 11:26:56 +03:00
* `reboot`
2017-01-16 20:10:20 +03:00
2017-02-01 11:26:56 +03:00
10. Get sysroot for cross compiling (password: root) (5 min)
2017-02-01 11:26:56 +03:00
* `cd $HOME/raspi && mkdir sysroot sysroot/usr sysroot/opt`
2017-02-01 11:26:56 +03:00
* `rsync -avz root@$RASPI_IP:/lib sysroot --delete`
2017-02-01 11:26:56 +03:00
* `rsync -avz root@$RASPI_IP:/usr/include sysroot/usr --delete`
2017-02-01 11:26:56 +03:00
* `rsync -avz root@$RASPI_IP:/usr/lib sysroot/usr --delete`
2017-02-01 11:26:56 +03:00
* `rsync -avz root@$RASPI_IP:/opt/vc sysroot/opt --delete`
2017-02-01 11:26:56 +03:00
11. Prepare sysroot; you can also define a custom location with **RPI1_SYSROOT_DIR**, **RPI2_SYSROOT_DIR** or **RPI3_SYSROOT_DIR** (but then you might need to manually change commands from here on during the setup)
2017-02-01 11:26:56 +03:00
* `cd $HOME/raspi && wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py`
* `chmod +x sysroot-relativelinks.py && ./sysroot-relativelinks.py sysroot`
2017-02-01 11:26:56 +03:00
12. Build Qt (2 hours)
* `cd $HOME/raspi/qt-everywhere-opensource-src-5.8.0`
2017-02-01 11:26:56 +03:00
* make sure `QT_DIR` points to your desktop installation of Qt; you may also want to tweak the configure command below, if you put the tools or the sysroot in an alternative location
2017-02-01 11:26:56 +03:00
* Raspberry Pi 1
* `./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi1 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 2
* `./configure -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi2 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
2017-01-16 20:10:20 +03:00
2017-02-01 11:26:56 +03:00
* Raspberry Pi 3
* `./configure -opengl es2 -device linux-rpi3-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi3 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
2017-02-01 11:26:56 +03:00
* `make -k -i && sudo make -k -i install`
2017-02-01 11:26:56 +03:00
13. Prepare the Qt directory
2017-02-01 11:26:56 +03:00
* `sudo chown -R $USER $QT_DIR`
2017-02-01 11:26:56 +03:00
14. Install and test the binding (20 min)
2017-02-01 11:26:56 +03:00
* Raspberry Pi 1
* `$GOPATH/bin/qtsetup rpi1`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 2
* `$GOPATH/bin/qtsetup rpi2`
2017-02-01 11:26:56 +03:00
* Raspberry Pi 3
* `$GOPATH/bin/qtsetup rpi3`
2016-09-18 22:55:19 +03:00
2017-02-01 11:26:56 +03:00
15. Notes
2016-09-18 22:55:19 +03:00
2017-02-01 11:26:56 +03:00
* run `startx &` before starting an application with `-platform xcb` (qml/quick applications won't work; they may work with Qt 5.8)
2017-02-01 11:26:56 +03:00
* run `weston &` or `weston --tty=1 &` (via ssh) or create your own [compositor](https://doc.qt.io/qt-5/qtwaylandcompositor-index.html) before starting an application with `-platform wayland-egl` (qml/quick applications won't work; they may work with Qt 5.8)
2017-02-01 11:26:56 +03:00
* you can increase the available gpu memory by editing `/boot/config.txt`
2017-02-01 11:26:56 +03:00
16. Create your first [application](#example)
2017-02-01 11:26:56 +03:00
17. Deploy applications with `$GOPATH/bin/qtdeploy build rpiX path/to/your/project` (replace X with 1, 2 or 3) (use the *.sh file to start your application)
</details>
2017-02-01 11:26:56 +03:00
* Docker
2017-02-01 11:26:56 +03:00
<details>
<summary>Docker</summary>
2017-02-01 11:26:56 +03:00
1. Install the desktop version for Windows, macOS or Linux
2017-02-01 11:26:56 +03:00
2. Install and start [Docker](https://www.docker.com)
2017-02-01 11:26:56 +03:00
3. Share your **GOPATH** host directory as a [data volume](https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume) with Docker.
And make sure your Project folder is in your **GOPATH**.
2017-02-01 11:26:56 +03:00
4. Download the necessary Docker image(s) and run the setup.
2016-10-28 05:00:58 +03:00
2017-02-01 11:26:56 +03:00
* For cross compiling to Windows:
2017-02-01 11:26:56 +03:00
* `docker pull therecipe/qt:base_windows` (to deploy 32-bit applications)
2016-11-12 18:06:57 +03:00
2017-02-01 11:26:56 +03:00
* `docker pull therecipe/qt:base_windows_64` (to deploy 64-bit applications)
2017-02-01 11:26:56 +03:00
* **Optional:** Install [Wine](https://www.winehq.org) to test your applications.
2017-02-01 11:26:56 +03:00
* define `QT_MXE_ARCH=386` to deploy 32-bit applications or `QT_MXE_ARCH=amd64` to deploy 64-bit applications
2016-11-12 18:06:57 +03:00
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup windows-docker`
2017-02-01 11:26:56 +03:00
* Deploy applications with `$GOPATH/bin/qtdeploy build windows path/to/your/project docker`
2017-02-01 11:26:56 +03:00
* For cross compiling to Linux:
2017-02-01 11:26:56 +03:00
* `docker pull therecipe/qt:base`
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup linux-docker`
2017-02-01 11:26:56 +03:00
* Deploy applications with `$GOPATH/bin/qtdeploy build linux path/to/your/project docker`
2017-02-01 11:26:56 +03:00
* For cross compiling to Android:
2017-02-01 11:26:56 +03:00
* `docker pull therecipe/qt:base_android`
2017-02-01 11:26:56 +03:00
* `$GOPATH/bin/qtsetup android-docker`
2017-02-01 11:26:56 +03:00
* Deploy applications with `$GOPATH/bin/qtdeploy build android path/to/your/project docker`
</details>
## Code Editor Settings (for code completion)
2016-11-02 23:49:24 +03:00
* IntelliJ Idea
Help > Edit Custom Properties
```
# custom IntelliJ IDEA properties
idea.max.intellisense.filesize=999999
```
Help > Edit Custom VM Options
```
# custom IntelliJ IDEA VM options
-Xms128m
2016-12-30 23:40:48 +03:00
-Xmx4000m
-XX:ReservedCodeCacheSize=512m
2016-11-02 23:49:24 +03:00
-XX:+UseCompressedOops
```
* Neovim
Update your neocomplete.vim
```
let g:neocomplete#skip_auto_completion_time = ""
```
* On windows you might also need to export `CGO_ENABLED=1` and `GOARCH=386`
## Example
1. Create a project folder `[GOPATH]/src/qtExample`
2015-11-19 21:29:30 +03:00
2. Create a file `[GOPATH]/src/qtExample/main.go`
2017-02-01 11:26:56 +03:00
<details>
<summary>main.go (click to expand)</summary>
```go
package main
import (
2015-12-18 21:03:39 +03:00
"os"
2015-11-19 21:29:30 +03:00
"github.com/therecipe/qt/core"
2015-12-18 21:03:39 +03:00
"github.com/therecipe/qt/widgets"
)
func main() {
2015-12-18 21:03:39 +03:00
widgets.NewQApplication(len(os.Args), os.Args)
2015-11-19 21:29:30 +03:00
2016-12-17 23:52:41 +03:00
//create a window
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.SetMinimumSize2(200, 200)
//create a layout
var layout = widgets.NewQVBoxLayout()
//add the layout to the centralWidget
var centralWidget = widgets.NewQWidget(window, 0)
centralWidget.SetLayout(layout)
//create a button and connect the clicked signal
var button = widgets.NewQPushButton2("Click me!", nil)
button.ConnectClicked(func(flag bool) {
widgets.QMessageBox_Information(nil, "OK", "You clicked me!", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
2015-12-18 21:03:39 +03:00
})
2015-11-19 21:29:30 +03:00
2016-12-17 23:52:41 +03:00
//add the button to the layout
layout.AddWidget(button, 0, core.Qt__AlignCenter)
2016-12-17 23:52:41 +03:00
//add the centralWidget to the window and show the window
window.SetCentralWidget(centralWidget)
2015-12-18 21:03:39 +03:00
window.Show()
2015-11-19 21:29:30 +03:00
2015-12-18 21:03:39 +03:00
widgets.QApplication_Exec()
}
2017-02-01 11:26:56 +03:00
```
</details>
2016-10-30 00:28:13 +03:00
3. Open the terminal in `[GOPATH]/src` and run `[GOPATH]/bin/qtdeploy build desktop ./qtExample`
2015-11-19 21:29:30 +03:00
4. You will find the application in `[GOPATH]/src/qtExample/deploy/[GOOS]/`
5. Take a look at the [examples](https://github.com/therecipe/qt/tree/master/internal/examples)
6. Make yourself familiar with the [Qt documentation](https://doc.qt.io/qt-5/classes.html)
7. Join our Slack Channel [#qt-binding](https://gophers.slack.com/messages/qt-binding/details/)
## More extensive examples / demos / applications
* [5k3105/AM](https://github.com/5k3105/AM)
* [5k3105/Pipeline-Editor](https://github.com/5k3105/Pipeline-Editor)
2017-01-08 22:14:18 +03:00
* [5k3105/Sprite-Editor](https://github.com/5k3105/Sprite-Editor)
* [gen2brain/url2img](https://github.com/gen2brain/url2img)
* [joeblew99/qt-archi](https://github.com/joeblew99/qt-archi)
* [jordanorelli/grpc-ui](https://github.com/jordanorelli/grpc-ui)
2017-02-01 18:38:51 +03:00
* [Matt-Texier/local-mitigation-agent](https://github.com/Matt-Texier/local-mitigation-agent)