cutego/README.md

373 lines
12 KiB
Markdown
Raw Normal View History

## Screenshots
### Windows
![](internal/screens/windows.png)
### macOS
![](internal/screens/mac.png)
### Linux
![](internal/screens/linux.png)
### Android
#### Portrait
![](internal/screens/android_portrait.png)
#### Landscape
![](internal/screens/android_landscape.png)
### iOS
2016-05-15 23:07:05 +03:00
#### Portrait
2016-05-15 23:07:05 +03:00
![](internal/screens/ios_portrait.png)
#### Landscape
2016-05-15 23:07:05 +03:00
![](internal/screens/ios_landscape.png)
### Sailfish OS
2016-06-11 02:50:53 +03:00
![](internal/screens/sailfish_portrait.png)
---
---
## Installation
2014-12-02 23:51:56 +03:00
* Desktop
2016-09-16 21:09:44 +03:00
* [Windows](#windows-1)
* [macOS](#macos-1)
* [Linux](#linux-1)
2014-12-02 23:51:56 +03:00
* Mobile
2016-09-16 21:09:44 +03:00
* [Android](#android-1)
* [iOS](#ios-1)
* [Sailfish OS](#sailfish-os-1)
2014-12-02 23:51:56 +03:00
* Embedded
* [Raspberry Pi](#raspberry-pi)
2014-12-02 23:51:56 +03:00
---
## Windows
2014-12-02 23:51: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
* https://storage.googleapis.com/golang/go1.7.1.windows-amd64.msi
2014-12-02 23:51:56 +03:00
2. Install Qt 5.7.0 in `C:\Qt\Qt5.7.0\`
2014-12-02 23:51:56 +03:00
* https://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-windows-x86-android-5.7.0.exe
2014-12-02 23:51:56 +03:00
3. Add the directory that contains **gcc.exe** and **g++.exe** to your **PATH**
2014-12-02 23:51:56 +03:00
* `C:\Qt\Qt5.7.0\Tools\mingw530_32\bin\`
2014-12-02 23:51:56 +03:00
4. Download the binding
2015-11-09 20:23:42 +03:00
* `go get -d github.com/therecipe/qt`
2015-11-09 20:23:42 +03:00
2015-10-24 18:18:24 +03:00
5. Generate, install and test
2014-12-02 23:51:56 +03:00
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat` **(run as admin)**
6. Create your first [application](#example)
## macOS
1. Install Go >= 1.7.1 and setup a proper [**GOPATH**](https://golang.org/doc/code.html#GOPATH)
* https://storage.googleapis.com/golang/go1.7.1.darwin-amd64.pkg
2. Prepare the Qt installation directory
* `QT_INSTALL_DIR=/usr/local/Qt5.7.0/; sudo mkdir $QT_INSTALL_DIR && sudo chown $USER $QT_INSTALL_DIR`
3. Prepare the go directory
* `sudo chown -R $USER /usr/local/go/`
4. Install Qt 5.7.0 in `/usr/local/Qt5.7.0/`
* without iOS https://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-mac-x64-android-5.7.0.dmg
* with iOS https://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-mac-x64-android-ios-5.7.0.dmg
5. Install **Xcode** >= 7.3.1
* https://itunes.apple.com/us/app/xcode/id497799835
6. Download the binding
* `go get -d github.com/therecipe/qt`
7. Generate, install and test
2014-12-02 23:51:56 +03:00
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh`
2015-11-09 20:23:42 +03:00
8. Create your first [application](#example)
## Linux
1. Install Go >= 1.7.1 and setup a proper [**GOPATH**](https://golang.org/doc/code.html#GOPATH)
* https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
2. Prepare the Qt installation directory
* `QT_INSTALL_DIR=/usr/local/Qt5.7.0/; sudo mkdir $QT_INSTALL_DIR && sudo chown $USER $QT_INSTALL_DIR`
3. Prepare the go directory
* `sudo chown -R $USER /usr/local/go/`
4. Install Qt 5.7.0 in `/usr/local/Qt5.7.0/`
* https://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-android-5.7.0.run
5. Install **g++** and **OpenGL** dependencies
* `sudo apt-get -y install build-essential mesa-common-dev`
6. Download the binding
* `go get -d github.com/therecipe/qt`
7. Generate, install and test
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh`
8. Create your first [application](#example)
2014-12-02 23:51:56 +03:00
---
2016-06-11 02:50:53 +03:00
## Android
2014-12-02 23:51:56 +03:00
1. Install the desktop version
2014-12-02 23:51:56 +03:00
2. Install the Android SDK in `C:\android\android-sdk\` or `/opt/android-sdk/`
* https://dl.google.com/android/android-sdk_r24.4.1-windows.zip
* https://dl.google.com/android/android-sdk_r24.4.1-macosx.zip
* https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
2014-12-02 23:51:56 +03:00
3. Install the SDK dependencies with `C:\android\android-sdk\tools\android.bat` or `/opt/android-sdk/tools/android`
2015-11-09 20:23:42 +03:00
* Tools
* Android SDK Build-tools (24.0.2)
2016-08-14 19:53:08 +03:00
* Android 7.0 (API 24)
2015-11-09 20:23:42 +03:00
* SDK Platform
2015-11-12 03:29:32 +03:00
* Extras (Windows only)
* Google USB Driver
2014-12-02 23:51:56 +03:00
4. Install the Android NDK in `C:\android\android-ndk\` or `/opt/android-ndk/`
* https://dl.google.com/android/repository/android-ndk-r12b-windows-x86_64.zip
* https://dl.google.com/android/repository/android-ndk-r12b-darwin-x86_64.zip
* https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
2014-12-02 23:51:56 +03:00
5. Install Java SE Development Kit (Linux: install in `/opt/jdk/`)
* https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2014-12-02 23:51:56 +03:00
6. Install and test
2014-12-02 23:51:56 +03:00
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat android` **(run as admin)**
2014-12-02 23:51:56 +03:00
or
2014-12-02 23:51:56 +03:00
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh android`
7. Create your first [application](#example)
2016-06-11 02:50:53 +03:00
## iOS
2016-05-15 23:07:05 +03:00
2016-09-16 21:09:44 +03:00
1. Install the desktop version for [macOS](#macos-1)
2016-05-15 23:07:05 +03:00
2. Install and test
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh ios && ./setup.sh ios-simulator`
2016-05-15 23:07:05 +03:00
3. Create your first [application](#example)
2016-05-15 23:07:05 +03:00
2016-06-11 02:50:53 +03:00
## Sailfish OS
1. Install the desktop version
2016-06-11 02:50:53 +03:00
2. Install VirtualBox
* https://download.virtualbox.org/virtualbox/5.1.4/VirtualBox-5.1.4-110228-Win.exe
* https://download.virtualbox.org/virtualbox/5.1.4/VirtualBox-5.1.4-110228-OSX.dmg
* https://download.virtualbox.org/virtualbox/5.1.4/VirtualBox-5.1.4-110228-Linux_amd64.run
2016-06-11 02:50:53 +03:00
3. Install the Sailfish OS SDK in `C:\SailfishOS\` or `/opt/SailfishOS/`
* https://releases.sailfishos.org/sdk/installers/1608/SailfishOSSDK-Beta-1608-Qt5-windows-offline.exe
* https://releases.sailfishos.org/sdk/installers/1608/SailfishOSSDK-Beta-1608-Qt5-mac-offline.dmg
* https://releases.sailfishos.org/sdk/installers/1608/SailfishOSSDK-Beta-1608-Qt5-linux-64-offline.run
2016-06-11 02:50:53 +03:00
4. Install and test
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat sailfish && setup.bat sailfish-emulator` **(run as admin)**
or
2016-06-11 02:50:53 +03:00
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh sailfish && ./setup.sh sailfish-emulator`
2016-06-11 02:50:53 +03:00
5. Create your first [application](#example)
2016-06-11 02:50:53 +03:00
---
## Raspberry Pi
2016-09-16 21:09:44 +03:00
1. Install the desktop version for [Linux](#linux-1)
2. Create a folder `[HOME]/raspi`
* `mkdir ~/raspi`
3. Download and unpack the Qt 5.7.0 source
2015-11-19 21:29:30 +03:00
* `cd ~/raspi && wget https://download.qt.io/official_releases/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.gz`
* `tar -xzf qt-everywhere-opensource-src-5.7.0.tar.gz qt-everywhere-opensource-src-5.7.0`
4. Download the cross compiler
* `cd ~/raspi && git clone https://github.com/raspberrypi/tools.git`
5. Install Arch Linux on your SD card
* `sudo apt-get -y install bsdtar`
* Raspberry Pi 1
* https://archlinuxarm.org/platforms/armv6/raspberry-pi
* Raspberry Pi 2 (**currently not working**)
* https://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2
* Raspberry Pi 3 (**currently not working**)
* https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
6. Start your Raspberry Pi
7. Enable root login over ssh
* `export RASPI_IP=192.168.XXX.XXX` (replace XXX.XXX with the valid ip ending)
* `ssh alarm@$RASPI_IP` (password: alarm)
* `su` (password: root)
* `sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config && sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config && systemctl restart sshd.service`
8. Update and install dependencies
* `pacman -Syu`
* `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 rsync`
* `pacman -Scc`
* `echo 'exec startlxde' >> ~/.xinitrc`
* `startx & exit`
9. Get sysroot for cross compiling (password: root)
* `cd ~/raspi && mkdir sysroot sysroot/usr sysroot/opt`
* `rsync -avz root@$RASPI_IP:/lib sysroot --delete`
* `rsync -avz root@$RASPI_IP:/usr/include sysroot/usr --delete`
* `rsync -avz root@$RASPI_IP:/usr/lib sysroot/usr --delete`
* `rsync -avz root@$RASPI_IP:/opt/vc sysroot/opt --delete`
10. Fix sysroot
* `cd ~/raspi && wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py`
* `chmod +x sysroot-relativelinks.py && ./sysroot-relativelinks.py sysroot`
11. Build Qt
* `cd ~/raspi/qt-everywhere-opensource-src-5.7.0`
* Raspberry Pi 1
* `./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix /usr/local/Qt5.7.0/5.7/rpi1 -I ~/raspi/sysroot/opt/vc/include -I ~/raspi/sysroot/opt/vc/include/interface/vcos -I ~/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I ~/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
* Raspberry Pi 2 (**currently not working**)
* `./configure -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -nomake tools -nomake examples -extprefix /usr/local/Qt5.7.0/5.7/rpi2 -I ~/raspi/sysroot/opt/vc/include -I ~/raspi/sysroot/opt/vc/include/interface/vcos -I ~/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I ~/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
* Raspberry Pi 3 (**currently not working**)
* `./configure -opengl es2 -device linux-rpi3-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -nomake tools -nomake examples -extprefix /usr/local/Qt5.7.0/5.7/rpi3 -I ~/raspi/sysroot/opt/vc/include -I ~/raspi/sysroot/opt/vc/include/interface/vcos -I ~/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I ~/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent`
* `make && sudo make install`
12. Prepare the Qt directory
* `sudo chown -R $USER /usr/local/Qt5.7.0/`
13. Install the binding
* Raspberry Pi 1
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi1`
* Raspberry Pi 2 (**currently not working**)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi2`
* Raspberry Pi 3 (**currently not working**)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi3`
14. Notes
* run `startx` (if not already running) before starting an application with `-platform xcb`
* most examples in [examples/quick](https://github.com/therecipe/qt/tree/master/internal/examples/quick) won't work because they use `quick.NewQQuickView`; use `quick.NewQQuickWidget` or `qml.NewQQmlApplicationEngine` instead
* you can increase the available gpu memory by editing `/boot/config.txt`
15. Create your first [application](#example)
---
---
## 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`
```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
//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
//create a layout and add the button
var layout = widgets.NewQVBoxLayout()
layout.AddWidget(button, 0, core.Qt__AlignCenter)
//create a window, add the layout and show the window
2015-12-18 21:03:39 +03:00
var window = widgets.NewQMainWindow(nil, 0)
window.SetWindowTitle("Hello World Example")
window.SetMinimumSize2(200, 200)
window.Layout().DestroyQObject()
window.SetLayout(layout)
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()
}
```
3. Open the { command-line | terminal | shell } in `[GOPATH]/src/qtExample` and run `qtdeploy build desktop`
2015-11-19 21:29:30 +03:00
4. You will find the application in `[GOPATH]/src/qtExample/deploy/[GOOS]/qtExample`
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)