Simple QML binding for Go

Qamel

GoDoc Docker Donate Donate

Qamel is a simple QML binding for Go, heavily inspired by therecipe/qt. This package only binds Qt's classes that used for creating a simple QML app, i.e. QApplication, QQuickView and QQMLApplicationEngine. It's still work-in progress, however it should be stable enough to use in production (as in I'm already using it in prod without problem, your situations may vary).

Features

  • Published under MIT License, which means you can use this binding for whatever you want.
  • Since it only binds the small set of Qt's class, the build time is quite fast.
  • It's available as Docker image, which means you can create QML app without installing Qt in your PC. Go is still needed though.
  • The binding itself is really simple and small. I also think I did a good job on commenting my code, so people should be able to fork it easily.
  • It supports live reload which is really useful while working on GUI.

Limitation

  • I've only tested this in Linux and Windows, so I'm not sure about Mac OS. It should works though, since the code itself is really simple.
  • When declaring custom QML object, this binding only supports basic data type, i.e. int, int32, int64, float32, float64, bool and string. For other data type like struct, array or map, you have to use string type and pass it as JSON value.
  • Thanks to Go and Qt, in theory, the app built using this binding can be cross compiled from and to Windows, Linux and MacOS. However, since I only have Linux and Windows PC, I only able to test cross compiling between Linux and Windows.

Development Status

I've created this binding for my job, so it's actively maintained. However, since I created it for the sake of the job, if the issues are not critical and doesn't affect my job or workflow, it might take a long time before I work on it. Therefore, all PRs and contributors will always be welcomed.

Resources

All documentation for this binding is available in wiki and GoDoc. There are some important sections in wiki that I recommend you to check before you start developing your QML app :

You might also want to check Qt's official documentation about QML :

For demo, you can check out Qamel-HN, a HackerNews reader built with QML and Go.

Licenses

Qamel is distributed under MIT license, which means you can use and modify it however you want. However, if you make an enhancement for it, if possible, please send a pull request. If you like this project, please consider donating to me either via PayPal or Ko-Fi.

Comments
  • go get github.com/RadhiFadlillah/qamel/qamel: no matching versions for query

    go get github.com/RadhiFadlillah/qamel/qamel: no matching versions for query "latest"

    Hey there, I tried to follow the install instructions but when I run:

     go get -u -v github.com/RadhiFadlillah/qamel/qamel   
    

    I get the following error:

    go: finding github.com/RadhiFadlillah/qamel/qamel latest
    go: finding github.com/RadhiFadlillah/qamel latest
    Fetching https://github.com?go-get=1
    Parsing meta tags from https://github.com?go-get=1 (status code 200)
    go get github.com/RadhiFadlillah/qamel/qamel: no matching versions for query "latest"
    

    With the second command, which I assume is because the first one failed, though, I get:

    # github.com/RadhiFadlillah/qamel
    application.cpp:2:10: fatal error: QApplication: No such file or directory
     #include <QApplication>
              ^~~~~~~~~~~~~~
    compilation terminated.
    

    Thanks, -MH

  • Can`t build app

    Can`t build app

    Hallo .

    qamel build -o output/desktop-app.exe --copy-deps
    Starting build process.
    
    Load config file...done
    Removing old build files...done
    Generating binding files...done
    Generating Qt resource file...done
    Generating syso file...icon file doesn't exist
    Generating code for QML objects...done
    Building app...
    Failed to build app : exit status 1
    go build github.com/RadhiFadlillah/qamel: E:\Go\pkg\tool\windows_amd64\cgo.exe:  exit status 2
    

    How can i solve this problem? Thanks.

  • qamel docker win64 --copy-deps blocked

    qamel docker win64 --copy-deps blocked

    ~/go/src/github.com/RadhiFadlillah/qamel/example/hello-world ‹master›$ qamel docker win64 --copy-deps                                                                           
    Run `qamel build` from Docker image.
    Starting build process.
    
    Load config file...done
    Removing old build files...done
    Generating binding files...done
    Generating Qt resource file...done
    Generating syso file...icon file doesn't exist
    Generating code for QML objects...done
    Building app...done
    Copying dependencies...
    

    I waited for half an hour, the size has not increased

    ~/go/src/github.com/RadhiFadlillah/qamel/example/hello-world ‹master›$ du -sh .
    3.3M    .
    
    

    The generated exe file can work in windows.

  • fail to run with error 'GLIBC_2.25' not found

    fail to run with error 'GLIBC_2.25' not found

    I use hello world demo and build with

    qamel docker linux-static
    

    Build finished successfully. but when I run, I got error

    /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found
    

    My platform is ubuntu16.04

    It is better if could build everything with static link.

  • build failed, like issue #15

    build failed, like issue #15

    D:\go_dev\src\go_qml>qamel build Starting build process.

    Load config file...done Generating vendor files...done Removing old build files...done Generating binding files...done Generating Qt resource file...done Generating syso file...icon file doesn't exist Generating code for QML objects...done Building app... Failed to build app: exit status 2

    github.com/go-qamel/qamel

    application.cpp:2:10: fatal error: QApplication: No such file or directory #include ^~~~~~~~~~~~~~ compilation terminated.

    D:\go_dev\src\go_qml>go env set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Destiny_Xue\AppData\Local\go-build set GOENV=C:\Users\Destiny_Xue\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= -mod= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=D:\goproject set GOPRIVATE= set GOPROXY=https://goproxy.io set GOROOT=D:\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=D:\go_dev\src\go_qml\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\DESTIN~1\AppData\Local\Temp
    go-build459187446=/tmp/go-build -gno-record-gcc-switches

    D:\go_dev\src\go_qml>qamel profile print Details of profile default OS : windows Arch : amd64 Static : false Qmake : D:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\qmake.exe Moc : D:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\moc.exe Rcc : D:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin\rcc.exe Gcc : D:\Qt\Qt5.14.2\Tools\mingw730_64\bin\gcc.exe G++ : D:\Qt\Qt5.14.2\Tools\mingw730_64\bin\g++.exe Objdump : D:\Qt\Qt5.14.2\Tools\mingw730_64\bin\objdump.exe Windres : D:\Qt\Qt5.14.2\Tools\mingw730_64\bin\windres.exe

    D:\go_dev\src\go_qml>

  • Fix

    Fix "Failed to create syso file: exit status 1" error.

    Fix "Failed to create syso file: exit status 1" error when "windres.exe" is in the "Program Files (x86)" or "Program Files" path.

  • too many arguments in call to gap.NewScope

    too many arguments in call to gap.NewScope

    Hello! trying to run go get -u -v github.com/go-qamel/qamel/cmd/qamel I get this: go get -u -v github.com/go-qamel/qamel/cmd/qamel github.com/go-qamel/qamel (download) github.com/fatih/color (download) github.com/muesli/go-app-paths (download) github.com/mitchellh/go-homedir (download) github.com/spf13/cobra (download) github.com/inconshreveable/mousetrap (download) github.com/spf13/pflag (download) github.com/fatih/color/vendor/github.com/mattn/go-isatty github.com/inconshreveable/mousetrap github.com/go-qamel/qamel/internal/config github.com/mitchellh/go-homedir github.com/spf13/pflag github.com/muesli/go-app-paths github.com/fatih/color/vendor/github.com/mattn/go-colorable github.com/go-qamel/qamel/internal/generator github.com/fatih/color github.com/spf13/cobra github.com/go-qamel/qamel/internal/cmd

    github.com/go-qamel/qamel/internal/cmd

    C:\Users\gabri\go\src\github.com\go-qamel\qamel\internal\cmd\root.go:17:26: too many arguments in call to gap.NewScope have (gap.ScopeType, string, string) want (gap.ScopeType, string)

    thanks in advance

  • internal/cmd/root.go:17:26: too many arguments in call to gap.NewScope

    internal/cmd/root.go:17:26: too many arguments in call to gap.NewScope

    after downloading qamel,run go get -u -v github.com /go-qamel/qamel/cmd/qamel,

    throw an error:

    internal/cmd/root.go:17:26: too many arguments in call to gap.NewScope have (gap.ScopeType, string, string) want (gap.ScopeType,string)

    OS: Manjaro 19.0.2 Kyria Kernel: x86_64 Linux 5.5.8-1-MANJARO

  • Build failed on windows

    Build failed on windows

    When use qamel build on my windows 10 os, it failed with this info:

    `Starting build process.

    Load config file...done panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x18 pc=0x63b110]

    goroutine 1 [running]: github.com/go-qamel/qamel/internal/cmd.dirExists(0xc00005e1e0, 0x5a, 0x5) G:/working/golang_work/src/github.com/go-qamel/qamel/internal/cmd/utils.go:31 +0xa0 github.com/go-qamel/qamel/internal/cmd.buildHandler(0xc0000b6840, 0x8e80c8, 0x0, 0x0) G:/working/golang_work/src/github.com/go-qamel/qamel/internal/cmd/build.go:108 +0x63d github.com/spf13/cobra.(*Command).execute(0xc0000b6840, 0x8e80c8, 0x0, 0x0, 0xc0000b6840, 0x8e80c8) G:/working/golang_work/src/github.com/spf13/cobra/command.go:846 +0x2b1 github.com/spf13/cobra.(*Command).ExecuteC(0xc0000b6580, 0xc000043f50, 0xc0000a3f50, 0x405986) G:/working/golang_work/src/github.com/spf13/cobra/command.go:950 +0x350 github.com/spf13/cobra.(*Command).Execute(...) G:/working/golang_work/src/github.com/spf13/cobra/command.go:887 main.main() G:/working/golang_work/src/github.com/go-qamel/qamel/cmd/qamel/main.go:14 +0x63

    `

    How to solve this issue?pls.

    this is profile info:

    qamel profile print Details of profile default OS : windows Arch : amd64 Static : false Qmake : G:\Qt\Qt5_14_2\5.14.2\mingw73_64\bin\qmake.exe Moc : G:\Qt\Qt5_14_2\5.14.2\mingw73_64\bin\moc.exe Rcc : G:\Qt\Qt5_14_2\5.14.2\mingw73_64\bin\rcc.exe Gcc : G:\Qt\Qt5_14_2\Tools\mingw730_64\bin\gcc.exe G++ : G:\Qt\Qt5_14_2\Tools\mingw730_64\bin\g++.exe Objdump : G:\Qt\Qt5_14_2\Tools\mingw730_64\bin\objdump.exe Windres : G:\Qt\Qt5_14_2\Tools\mingw730_64\bin\windres.exe

  • Slide menu?

    Slide menu?

    Hey there, I like what this can do so far and am excited to use it. I didn't see anything similar in this demo, but are the slide out menus able to be used in this package? I know qamel said it was simple, but not sure if that means that things like slide menus were not able to be used or not.

    Thanks, -MH

  • qamel docker gen vendor failed: permission denied

    qamel docker gen vendor failed: permission denied

    hello-world ‹master›$ qamel docker linux -o build/hello
    Run `qamel build` from Docker image.
    Starting build process.
    
    Load config file...done
    Generating vendor files...
    Failed to vendor app: exit status 1
    go: github.com/RadhiFadlillah/[email protected]: mkdir /home/user/go/pkg: permission denied
    go: error loading module requirements
    
    Failed to build app using Docker: exit status 1
    

    If I run qamel build first, and then run qamel docker linux, it will be fine.

    hello-world ‹master›$ qamel build                      
    Starting build process.
    
    Load config file...done
    Generating vendor files...done
    Removing old build files...done
    Generating binding files...done
    Generating Qt resource file...done
    Generating code for QML objects...done
    Building app...done
    
    Build finished succesfully.
    
    
    hello-world ‹master›$ qamel docker linux -o build/hello
    Run `qamel build` from Docker image.
    Starting build process.
    
    Load config file...done
    Removing old build files...done
    Generating binding files...done
    Generating Qt resource file...done
    Generating code for QML objects...done
    Building app...done
    
    Build finished succesfully.
    
  • macOS build failed

    macOS build failed

    macOS big sur 11.4 Qt 5.14.2

    $ qamel build
    Starting build process.
    
    Load config file...done
    Generating vendor files...done
    Removing old build files...done
    Generating binding files...done
    Generating Qt resource file...done
    Generating code for QML objects...done
    Building app...
    Failed to build app: exit status 2
    # runtime/cgo
    In file included from _cgo_export.c:3:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:181:5: error: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    
  • Will this ever support Qt6?

    Will this ever support Qt6?

    Hello,

    Your binding library is the only solution I've managed to get working off the ground pretty easily.

    Thank you so much for you work.

    I've been wondering: is Qt6 support planned, and if it is, how do you estimate the complexity to make it work?

    Cheers Ian

  • Add arm64 support

    Add arm64 support

    This patch allows to build apps on arm64 platform. Tested on Pinephone (CPU Allwinner A64 ARM Quad core Cortex-A53, 64bit) running Mobian. Which is bullseye/sid Debian based.

    At this moment distro QT version is: 5.15.2

    $ uname -a Linux mobian 5.10-sunxi64 # 1 SMP PREEMPT Tue Dec 22 11:43:57 UTC 2020 aarch64 GNU/Linux

  • Qt 5.6 support for lowend platfroms (arm, mips)

    Qt 5.6 support for lowend platfroms (arm, mips)

    This is preliminary attempt to support Qt 5.6 on low end platforms.

    1. Strip Quick.Components, wdigets, svg to reduce memory.
    2. Application would have to spawn QGuiApplication and not QApplication.
    TODO:

    Add compile time config to spawn QApplication / QGuiApplication Move QtQuick Controls classes to a different go package (like QQuickStyle, currently deleted)

    It will be great if I am guided a bit on the TODO(s)

  • Backend swapRow errors

    Backend swapRow errors

    Getting started on Ubuntu 20.04, go version go1.14.4. I have Qt 5.9, 5.13.0(under therecipe), 5.14.2 and 5.15.0 installed. The 2 simpler examples build and run fine using the -p linux option. However any example with the Backend yield errors like this: listmodel.cpp: In member function ‘void QamelListModel::swapRow(int, int)’: listmodel.cpp:143:24: warning: ‘void QList::swap(int, int) [with T = QVariant]’ is deprecated: Use QList::swapItemsAt() [-Wdeprecated-declarations] 143 | _contents.swap(i, j); for listmodel and tablemodel (though neither is used in the example) when 5.13 and above are used and a different error for 5.9. Does anyone have any suggestions

A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022
Go binding for GTK
Go binding for GTK

go-gtk WHATS Go bindings for GTK SCREENSHOT INSTALL You can experiment with go-gtk by running the various example programs: git clone https://github.c

Jan 5, 2023
The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.

Note that this project is largely unmaintained as I don't have the time to do or support more development. Please consider using this fork instead: ht

Dec 29, 2022
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly

Introduction Qt is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on var

Jan 2, 2023
SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Dec 30, 2022
Qt binding for Go (Golang) aims get Go's compile speed again.

qt.go Qt5 binding for Go (Golang) without CGO that aims to achieve Go's native compile speeds. Instead of using common bindings and heavy C++ wrapper

Dec 19, 2022
Odile is a simple GUI for the croc utility by Schollz.
Odile is a simple GUI for the croc utility by Schollz.

Odile Odile is a simple GUI for the croc utility by Schollz. This program uses Fyne, a UI toolkit written in Go, as the graphical interface. Effort wa

Dec 17, 2022
QML support for the Go language

QML support for the Go language Documentation The introductory documentation as well as the detailed API documentation is available at gopkg.in/qml.v1

Dec 19, 2022
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022
mass-binding-target is a command line tool for generating binding target list by search plot files from disk.

mass-binding-target mass-binding-target is a command line tool for generating binding target list by search plot files from disk. Build Go 1.13 or new

Nov 5, 2021
A Go language binding for encodeing and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protocol.

bencode-go A Go language binding for encoding and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protoco

Nov 27, 2022
SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Jan 1, 2023
Reflectionless data binding for Go's net/http (not actively maintained)
Reflectionless data binding for Go's net/http (not actively maintained)

binding Reflectionless data binding for Go's net/http Features HTTP request data binding Data validation (custom and built-in) Error handling Benefits

Nov 18, 2022
Go binding for the cairo graphics library

go-cairo Go binding for the cairo graphics library Based on Dethe Elza's version https://bitbucket.org/dethe/gocairo but significantly extended and up

Dec 19, 2022
Go OpenCL (GOCL) Binding

gocl Go OpenCL (GOCL) Binding (http://www.gocl.org) Library documentation: http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ http://www.khron

Jan 25, 2022
OpenGL binding generator for Go

GoGL GoGL is an OpenGL binding generator for Go. No external dependencies like GLEW are needed. Install the OpenGL bindings For example, OpenGL 2.1 bi

Dec 25, 2022
Go binding for GTK
Go binding for GTK

go-gtk WHATS Go bindings for GTK SCREENSHOT INSTALL You can experiment with go-gtk by running the various example programs: git clone https://github.c

Jan 5, 2023
The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.

Note that this project is largely unmaintained as I don't have the time to do or support more development. Please consider using this fork instead: ht

Dec 29, 2022