Skip to content
chengxuncc edited this page Jun 27, 2019 · 17 revisions








What is the actual name of this binding ?

At the moment, the actual name for this binding is simply qt. We know it is kind of weird to say qt is binding for Qt. What's more, Qt itself is a registered trademark, so sooner or later the name for this binding must be changed. However, naming things is hard, which is why @therecipe until now still can't come up with another name, and the obvious one like goqt or qtgo already taken. If you have an idea for new name, you can make suggestion here.

What is the status for this binding ?

This binding is work in progress. However it is quite stable and most of Qt API is already accessible from this binding, so it should already contain everything you need to build a fully featured applications. If you still missing something, feel free to open an issue.

How to make donation for this project ?

At the moment, @therecipe doesn't accept any donation or patreon. It's because he has plan to secure the further development of this project with the help of dual license bussiness model, which is why he doesn't feel comfortable to accept donations.

Where is the documentation ?

Most of binding code is generated by generator, which is why there are no godoc entry for this package. However, when building Qt app you can use official Qt documentation because almost every Qt API is mapped by this binding to same or predictable name in Go.

I need some help. Where should I ask my question ?

Like any other GitHub projects, you can ask your question by creating new issue. You can also join #qt-binding Slack channel by inviting yourself here.


What are the system requirements ?

Go 1.8+ must be installed on your system. You also need 2.5 GB free RAM (which only needed during initial setup) and at least 5 GB free disk space. If you want, you can run minimal setup by exporting enviromental variable QT_STUB=true before running the setup, which thereby lower the system requirements.

Which version of Qt that I can use ?

This binding is already tested and confirmed works with Qt 5.6 onwards.

How to debug or profiling QML applications ?

  • Install an official Qt version.
  • Export environment variable QT_DEBUG_QML=true.
  • Run normal qtdeploy (-fast, go build and go run won't work).
  • Manually start the created binary with flag -qmljsdebugger=port:8080,block.
  • Open the generated using QtCreator.
  • For debugging, run Debug > Start Debugging > Attach to QML Port. For more detail, consult Qt documentation.
  • For profiling, run Analyze > QML Profiler. For more detail, consult Qt documentation.

Can I use WYSIWYG editors for creating UI ?

You can use WYSIWYG editor in QtCreator for making user interface for your app. If you use widgets, here is an example how to load the generated *.ui files. If you use QML, then the generated *.qml files can be used like hand written QML files.

How to make IDE's code completion works ?

On Windows, depending on your editor or IDE, you may also need to export GOARCH=386 to make the code completion work.

  • IntelliJ IDEA / GoLand

    Run Help > Edit Custom Properties, then add or modify following lines :

    # custom IntelliJ IDEA properties

    After that, modify IntelliJ IDEA VM options by running Help > Edit Custom VM Options, then add or modify following lines :

    # custom IntelliJ IDEA VM options
  • Neovim

    Update your neocomplete.vim :

    let g:neocomplete#skip_auto_completion_time = ""
  • Visual Studio Code

    On the latest version of vscode and vscode-go, code completion already works out of the box. However, if yours code completion doesn't work, it might be caused by gocode that vscode-go used for auto completion. For more details look here.

How to use continuous integration (CI) ?

There are a few possible ways how you can integrate this package into your CI or CD plan :

  • You could create your own docker image(s) on top of the pre-built docker images.
  • You could pull the docker images for your target and then automate your work inside the (disposable) container.
  • You could use the minimal setup, which only depends on Docker + Go and then use qtdeploy -docker build ....
  • You could look into the CI folder and the *.yml files in the root folder of this repository.


How to cast QObject ?

To cast QObject, fetch its pointer then create new QObject from the pointer. For example, if you want to cast parent of a QPushButton into QVBoxLayout, you can do it like this :

parent := pushButton.ParentWidget()
parentPtr := parent.Pointer()
vBox := widgets.NewQVBoxLayoutFromPointer(parentPtr)


How to make a contribution ?

Just like other open source projects, you can make a contribution by submitting issues or pull requests. However, because there are plans to dual license this binding, before submitting pull requests you have to sign Contributor License Agreement (CLA) which can be found here.


We are not lawyer, so every answer beneath this point should be taken with a grain of salt.

Why is this binding licensed under LGPL ?

There are many reasons, but the main reason is to secure the further development of this project.

What is the implication from using LGPL library in my Go app ?

LGPL is a free software license published by the Free Software Foundation (FSF). If an application using library that use LGPL license, then LGPL license insists that end user must be able to recombine or relink the application with a modified or different version of the LGPL library, to produce a modified executable :

0) Convey the Minimal Corresponding Source under the terms of this License, and the 
Corresponding Application Code in a form suitable for, and under terms that permit, the 
user to recombine or relink the Application with a modified version of the Linked Version 
to produce a modified Combined Work, in the manner specified by section 6 of the GNU 
GPL for conveying Corresponding Source.

This can be achieved using two method :

  • By static linking the library to your executable, but still giving its source code or object code so user can recompile your app using different version of library.
  • By dynamic linking the library to your executable, so user can easily change or install which version of library that he wants.

If you want to use this binding, there are two LGPL library that you will use, Qt and this binding (therecipe/qt).

By default, qtdeploy will generate an executable that use dynamic linking to Qt library, so you can just distribute the executable and user can install his own library. So, if you want to make a proprietary app, you still can safely use Qt.

Now the problem is on this binding. Package therecipe/qt is composed by two parts :

  • Tools like qtsetup, qtdeploy, qtrcc, qtmoc and qtminimal which used for generating binding code and compiling application into executable.
  • API that binding Go to Qt class, like widgets, quick, core, etc.

GPL FAQ explains that apps or tools with GPL and LGPL license can be used for developing and compiling closed source app :

Can I use GPL-covered editors such as GNU Emacs to develop nonfree programs? 
Can I use GPL-covered tools such as GCC to compile them?

Yes, because the copyright on the editors and tools does not cover the code you write. 
Using them does not place any restrictions, legally, on the license you use for your code.

With that said, code generated by qtmoc and qtrcc is yours, because the generated code by those tools is heavily derived from your instructions. However, code generated by qtsetup and qtminimal is still under LGPL, because the generated code is already explicitly declared as LGPL in this repository.

Now, your question can be changed into "What is the implication from using therecipe/qt APIs (which are generated by qtsetup or qtminimal and therefore have LGPL license) in my Go app ?"

Repeating above, LGPL license insists that end user must be able to recombine or relink the application with a modified or different version of the LGPL library, to produce a modified executable.

As we know, Go compile its code into one single executable file. Now, what happen if end user want to change the version of therecipe/qt. For example, you deploy your app on 21 June 2017 using commit 5b0427c, but when your user use your app on 20 July 2017, the latest version of therecipe/qt is 4e40d6b, so your user want to change his app, on his own, to use the latest version of therecipe/qt.

According to LGPL license, you have to comply with his wish. And since Go by default static linking all imported package, your only choice is :

  • Give him source code or object code for your app, with intructions on how to rebuild it.
  • Use dynamic linking which (at the moment) only works in Linux.

Can I make a commercial app with this binding ?

Short answer, yes, you can. As long as you fulfilled all restrictions of LGPL license which have been explained above, then there are no problems.

More specifically, commercial app in this section means any app that you created and in return makes money for you. For example :

  1. You have your own company, and you create an app to increase efficiency and revenue of your company.
  2. You are working for an organization, and you get paid to create an app for internal use of that organization.
  3. You are a freelancer, and you are hired by an individual, organization or company to create an app, and you get paid from it.
  4. You have created a ready-made software that you want to sell to specific user.

For the first case, you can do whatever you want with your own code and app. GPL and LGPL only affect code and app that you distribute to other parties. For the other cases, if they ask for your source code, then you must give it to them. Otherwise, you don't have to. However, if they want to re-sell your code or app, they also free to do so.

There is commercial license planned for this binding, which you can use to create commercial app without LGPL restrictions above.

Can I make a proprietary app with this binding ?

Unfortunately no, this binding with its LGPL license is not suitable to be used in closed source application that are intended to be distributed to the general public, even if the application is not for commercial use.

Even though library with LGPL license usually can be used for closed source app that created in other language like C++ and Java, it is different in Go. Go by default static linking all imported package then converted all code into a single executable that can be distributed easily. Therefore, if end user asking for your app's source code, you don't have any choice except giving it to him.

There is commercial license planned for this binding, which you can use to create commercial app without LGPL restrictions above.

Will this binding have commercial license ?

Yes, there are plans for commercial license of this binding. Almost all contributors has agreed to this, however @therecipe still has not decided which license to use.

Clone this wiki locally
You can’t perform that action at this time.