5 ms·
Miqt: MIT-licensed Qt bindings for Go
- rubymamis 2y ago> Yes. You must also meet your Qt license obligations: either use Qt dynamically-linked dll/so/dylib files under the LGPL, or, purchase a Qt commercial license for static linking. There is this misconception that you can't statically link under the LGPL. From my reading (non legal advice), LGPL supports static linking - you just have to release your object files alongside the binary to allow people to link them with different versions of Qt.
- deleted 2y ago[deleted]
- mappu 2y agoI also think that is legal. But if you are required to distribute additional object files, that does somewhat reduce the benefits of static linking - you might as well use dynamic linking in that case. It's also not completely trivial to do this with the Go linker.
- rubymamis 2y ago> But if you are required to distribute additional object files, that does somewhat reduce the benefits of static linking Because of the total increase in size? Maybe one can just share a link from which the object files can be downloaded?
- zerr 2y agoYou are not required to distribute those along with your app. You can just have them available for download separately if anyone needs it. LGPL requirement is the ability of the end user to relink (not recompile) the executable.
- mappu 2y agoYes, that's definitely possible. Note that the LGPL license says any such download must remain available for 3 years. Before GitHub, I used to host my projects on Google Code. After that service shutdown, I'm not comfortable with such a requirement.
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- mappu 2y agoHi, author here, ask me anything. (Qt 6 branch is nearly ready.)
- antibios 2y agoHey, I noticed that you reference other implementations. What's the rationale for a new implementation? Cheers
- mappu 2y agoThe main rationale is definitely the license. The existing bindings for Qt Widgets (therecipe/qt and kitech/qt.go) are LGPL. That's just really difficult to use in Go where static linking is the default behaviour. The other bindings have some strange behaviours when I checked them closely. - therecipe/qt: The design of the "qtbox" runtime for therecipe/qt, introduced before the maintainer went MIA. Now that we know the Jia Tan xz story, it's my hope that MIQT can be a "nothing up my sleeve" binding with a clear source code supply chain, with no prebuilt binaries. - kitech/qt.go: The rationale for their version was to focus on compilation speed, but with GOCACHE this is no longer really a problem. It also seems to be unmaintained.
- wiz21c 2y agohttps://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic https://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynami... You can have the LGPL'ed code but the price to pay is that your users give your objects files (i.e. pre-link stuff; but not the source code) so that your users can modify the LGPL code and rebuild your project with the modifications. Moreover: https://pkg.go.dev/cmd/link https://pkg.go.dev/cmd/link So it seems that you can have access to the object files. Overall, it is possible to make your bindings LGPL. I understand this is a bit trickier and not very user friendly. Or you could dual license. But well, it's a political choice, so I won't try to convince you :-)
- bmitc 2y agoDoes this support Qt Quick and QML?
- mappu 2y agoNo(t yet), i've focused on the traditional desktop Widgets toolkit. There are other existing QML/Go bindings you might be interested in. Qt Widgets has a lot of benefits over QML. It is native compiled code whereas QML is interpreted; the native compiler (qmlsc) is proprietary and only available for commercial licensees. If you are happy with a large runtime for an interpreted UI then I'd suggest looking at web technology (e.g. Wails) to enjoy the broader ecosystem effects.
- foresto 2y agoAlso, QML exposes only a fraction of the functionality of the Qt Widgets API.
- bmitc 2y agoAnd vice versa.
- rubymamis 2y agoFirst of all, I wrote a block editor in QML[1] (the model in C++) that far outperform QTextEdit (part of Qt Widgets) at loading, scrolling and word-wrap resizing of very large documents (think, War and Peace) *with* the additional cost of being a block editor that can include a Kanban board, images, etc. So saying QML isn't performant is incorrect. Secondly, my knowledge about the internal build tools such as qmltc, qmlcachegen, and qmlsc is quite limited, but isn't qmlcachegen also compiles QML documents[2]? And don't forget that the built-in Qt Quick components are either compiled to C++ or written natively in C++. [1] https://get-notes.com/ https://get-notes.com/ [2] https://doc.qt.io/qt-6/qtqml-qtquick-compiler-tech.html#summary https://doc.qt.io/qt-6/qtqml-qtquick-compiler-tech.html#summ...
- mappu 2y ago
- gen2brain 2y agoNice, thanks. All the other Qt bindings seem abandoned. https://github.com/kitech/qt.go https://github.com/kitech/qt.go is interesting though, it uses a huge wrapper, and then FFI calls. Now we can use libffi with purego (there is already a library) so in theory such a method can be used for CGo-free Qt bindings.
- mappu 2y agoA lot of kitech's work was in making the large C ABI wrapper. There's another C ABI wrapper already in Debian (libqt5pas) that might be possible to use directly.
- rob74 2y agoAh, that's a part of Lazarus (the "pas" at the end is a giveaway). Actually I've had this idea for some time that integrating Go into Lazarus might be worthwhile - I was a Delphi developer before I "jumped ship" to web development, but I still like the effortless way of building GUI applications with a proper GUI design tool, and Go's speed of compilation and some syntax elements make it appealing for Pascal developers (at least that's the way I felt when I first tried it). But not sure how the two communities would feel about this idea...
- shagrath 2y agoYou might like this : https://github.com/ying32/govcl https://github.com/ying32/govcl
- mappu 2y agoI spent some time using the GoVCL bindings of Lazarus LCL, and made some small app with it: https://code.ivysaur.me/yvbolt https://code.ivysaur.me/yvbolt It does work, but I had hoped for more, it is simply too far behind in many ways and is stuck on GTK2 (so no high DPI support). The LCL itself does support GTK3 and Qt5 (and nothing newer), but recompiling GoVCL to use them broke quite badly.
- 2y ago
- azalemeth 2y agoI slightly lament the rise of MIT or BSD licensed middleware like this. It's undoubtedly great for the developers and organisations in question, but there's undoubtedly some societal good from having GPL or LGPL licensed products encouraging organisations to release their code under a similar license. This already exists for Go and Qt, and the competing library is "soon" to release a commercial license that would be available for those who do not wish to use the LGPL. Nevertheless, huge props to the author(s) for what undoubtedly is a vast amount of work.
- dokyun 2y agoThere's a whole handful of permissively-licensed, feature-matched alternatives to GNU Readline that I suspect only exist due to political aversions to its license. It saddens me that these people would rather waste time treading over the same paths others have just to increase the potential for nonfree software, rather than using that time to write free and useful things.
- rty32 2y agoThat's your definition of "useful", not mine. "political aversion"? We are talking about money and business here. If a commercial company wants to ship a product without reinventing all the wheels, they are going to use code with permissive licenses, and skip projects with GPL license or similar in a heartbeat. You could even argue quite the contrary -- when you make your project GPL/AGPL etc, and if it is big/impactful enough, people will inevitably create alternative projects with permissive licenses that tried to match the feature set, and it is you that is the cause of all this "waste of time". Not necessarily a good argument, but there is some truth there. And thank god a lot of goodness actually comes out of it other than just reinventing the wheels. Apple "bought" LLVM due to gcc's copyleft license, and now we have a family new compilers based on LLVM for different languages and targets. Kudos to Apple.
- arp242 2y agoApple literally offered the clang/LLVM copyright to the FSF to be released under the GPL. This was basically just ignored. https://gcc.gnu.org/legacy-ml/gcc/2005-11/msg00888.html https://gcc.gnu.org/legacy-ml/gcc/2005-11/msg00888.html Furthermore there were real technical problems with gcc, certainly at the time. There were good reasons to start a new compiler project. The license was always more of a detail, rather than the main thing.
- sime2009 2y agoIs it possible to extend/subclass an existing QWidget and customise it?
- mappu 2y agoFor e.g. PaintEvent() from pure Go code? Not yet, but I have some idea on how to make it possible. Until then, a nice feature of CGO is you can write one custom Qt subclass in a .cpp file in the same folder as your .go files. Your C++ will be compiled with `go build`, and you can use your custom class directly from Go/MIQT. So even if some advanced Qt feature is not in the binding, anything is still possible at least. I'll make an example about this.
- sime2009 2y agoI contribute to NodeGui, Qt on Nodejs. It doesn't try to emulate the C++ API by allowing subclassing. Instead it exposes most methods on QWidget classes/subclasses which process QEvent objects (and their subclasses) in the form of events which you can subscribe to as an application. You can listen to signals and also QEvent related traffic in much the same way. So, if you want to subclass a QWidget to do your own custom rendering/painting, you would create an instance of QWidget and then listen to/hook into, the incoming requests to repaint. Qt sees a normal QWidget instance, but you can customise it do act like the subclass you desire. This avoids any attempt to do a real C++ subclass at runtime. Internally, NodeGui subclasses almost every QWidget (and more) to hook into them to allow this. This works far better than you might expect and saves a ton of complexity.
- c1b 2y agoWhat is this for exactly? Go should be used serverside, and Qt looks like its for UIs on embedded devices?
- Rochus 2y agoQt is a large framework and also includes e.g. a large network module which supported async event based communication long before there was Go. But it's unlikely that a Go application uses this, because Go has its own network library and even native language support for asynchronous communication (buffered channels). But Qt also has cross-platform user interface features even with 3D and OpenGl support, which might be useful for people using Go on the desktop.
- abtinf 2y ago> therecipe/qt is the most mature Qt binding for Go. It works by making IPC calls to a separate C++ binary downloaded at runtime from a site under the maintainer's control. WTF?
- voidfunc 2y agoYea.. that sounds like a non-starter for use.
- tomjen3 2y agoThis sounds like something that was a good idea to begin with - we should ensure the libraries can be MIT licensed by using a separate binary, then hitting the "most likely go developers don't want to setup a complex C++ compile chain" to "I known we will just precompile it" to "oh but where can I download it from" to "oh I have that server". Every step in the chain makes sense and is done with the best intention, but the result is, well. Been there done that. Didn't get the t-shirt.
- bitwize 2y agoReminds me of PS/Tk, a cross-platform, cross-implementation GUI library for Scheme that worked by opening a pipe to a Tcl/Tk process and communicating with that. It actually worked fairly well, though it's sadly abandoned now. I contributed somewhat by getting it working for Gambit.
- 2y ago
- chipdart 2y agoI have a question to the crowd. If you really like Go and you're already willing to adopt a solution based in making IPC calls to separate processes just to put together a GUI... ...why not write your GUI app in something production-ready that makes sense to write a GUI, and have that call your Go process ?
- randomdata 2y agoHow are you going to run on X11 systems if you have ruled out making IPC calls to a separate process in order to put together a GUI? Anyway, the primary advantages of the separate process you speak of is that it: 1. Deals with the LGPL concerns for you. 2. Deals with the pains of compilation, and especially cross-compilation for you. That is why you might consider it. Of course, it comes with many disadvantages too. Tradeoffs, as always.
- chipdart 2y ago> How are you going to run on X11 systems if (...) I'm not sure you understood the question I asked.
- randomdata 2y agoPerhaps it is actually you who misunderstood my question?
- mappu 2y agoI currently do this at $DAYJOB with a C++/Qt GUI talking to a Go daemon. It's fine but eventually the busywork in marshalling is a headache, and it doesn't scale well for large amounts of data. I can see some advantage of the therecipe/qt "qtbox" idea. Even though the same marshalling is present, you get to write everything still in one language, the cross-language part is hidden from you. In either case, it's great that MIQT now lets you avoid this, and write everything in Go with no IPC marshalling at all.
- chipdart 2y ago