Qt binding for Go with support for all major operating systems
github.com
github.com
Next time I want to build a desktop app I'll have a go with this for definite.
Then I remember that I'd be managing a custom heterogenous compute cluster just to compile some code.
No hard feelings :)
I would prefer Rust for this (or, well, I would prefer Python with a better packaging story), but Go is much better than the alternatives too.
Once I have been building Qt Widgets application in Python with PySide bindings. I needed to do some simple processing in several SLOTs and decided to use lambdas as an easy replacement. Kids, do not even think about attempting to do this at home, seriously.
I have run into some extremely evasive random crashes and stuff. I did not dig to the bottom of the issue, although my guess is that Python lambdas are executed in main (constructing) thread context and that causes race conditions.
My question: how do Golang's goroutines interact with native threads spawned by Qt?
Working with QT bindings is very difficult. Debuging things is not easy. I'm not sure if using bindings is worth it. I suspect doing things in plain C++ QT might be easier to debug and maintain.
Qt is generally type safe, but it uses quite a lot of pointer types and also a rather unusual for C++ parent-child resource cleanup rule for QObjects (e.g. all widgets).
When something does crash, C++ doesn't offer any tracebacks, but if one has a core dump or can reproduce the crash under a debugger, a traceback can be easily obtained in the majority of cases.
how do you create core dump? starting program under some debugger? I tried debugging with valgrind but the output contained so much noise it took my ages to find something. I also had to recompile QT used by PyQT because QT because QT requires some flags to be able to debug. What's the best way to debug things like this?
Valgrind is not really useful for debugging crashes. Running under gdb would work though.
If one can run the target program under a debugger, a core dump is not so helpful because it's a static snapshot, whereas a debugger can modify program state.
I am guessing that one has to run the python process itself under the debugger and pass the parameters such as the script path.
There will probably be a signal or exception condition at one point and one can take a look at the call stack. The call stack will probably be messy, as it will include python internals.
An alternative way to debug this is to understand the lifetimes and preconditions of C++ widgets and signals and slots and review one's python code.
Unless there's a bug in Qt itself, PyQt and Qt might have a misunderstanding about lifetimes and something gets cleaned up too soon or there's a dangling refrence to a cleaned up object
I've fixed crashes by keeping stuff assigned to variables to keep it from being GCed.
In this case, you're depending on the Qt side (signal/slot management) to keep your lambda alive along with its entire call stack. But python doesn't know anything about QObject pointers, and will happily GC it. The next time that signal is fired, crash is extremely likely.
This used to be a much bigger problem in PyQt and PySide 4 and earlier, but it appears to have gotten better recently in PyQt at least.
In general, the best way to work with Qt is to let it assume control, and it use its mechanisms for lifecycle-management. I converted the code so that it used a QThread-derived Python class and QTimer. Works great.
You basically have to understand the Deep Magic that makes Python work under the hood, and ditto for Qt, too.
Sidenote: It's also possible to build Qt applications in Python using AsyncIO (using quamash), by integrating the Qt event loop as an AsyncIO event loop. This can be helpful to avoid race conditions, as much more interactions can be handled without thread concurrency.
I managed to use pyqt and autobahn|python (wamp protocol, RPC and pub/sub) in the same app thanks to quamash.
I set up an example app here https://github.com/icefo/PyQt5-Wamp
edit: can't comment any further currently, I will try to answer everything once I'm unblocked.
We've marked your account legit so it won't happen again. Welcome to HN!
[0]https://m.reddit.com/r/golang/comments/585rvs/comment/d8xtre...
8GB RAM is rather optimistic.
edit: can't comment any further currently, I will try to answer everything once I'm unblocked.
Last I saw, QT's GPL/LGPL license required you to open-source the code that was statically linked to it. That wasn't much of a problem for desktop platforms, as you could just package up all of QT into its own QT.DLL (or the equivalent) and link to it dynamically. But this isn't allowed on stuff like iOS, so you were required to buy a license for those.
And it's a bit of a misconception that LGPL requires statically linked things to be open sourced: in that area it only requires that the LGPL components be replaceable (and the source for the LGPL components be available). In the context of static linking, that can be done by releasing pre-link binaries (object files) with instructions for linking them.
Of course, that's likely more work than just making the source available under a proprietary license (ie: provide source code so LGPL components can be replaced).
If you're using Qt GPL components, then yes, you'll need to open source your application (or pay for a Qt License)
edit: can't comment any further currently, I will try to answer everything once I'm unblocked.
Some of the language bindings that aren't maintained by Digia are still GPL, though. An example of this is PyQt, and the PyQt team's intransigence on the GPL is why PySide exists.
QT is Apple QuickTime which some consider as the worst Windows software ever created.
I was guilty of mispronouncing it too, until Qt 4 came out and they released that goofy "Qt 4 dance" video.
a) Qt doesn't use native controls on any platforms (though for half of desktop Linuxes Qt is the native toolkit). Qt has its own controls that are styled to look like native.
b) The screenshot shows Qt widgets. This is not the intended way to do Qt on mobile platforms, and thus no native styling is provided. QML is the official way to do mobile apps with Qt.
Other minor Qt annoyances include their own scrollbars which ignore the system setting of "jump to where I click the thumb" setting etc.
I raised two small issues, and both were addressed quickly by the author. In one case incredibly quickly.
edit: can't comment any further currently, I will try to answer everything once I'm unblocked.
edit: can't comment any further currently, I will try to answer everything once I'm unblocked.
I mean, yes, its statically linked but 52 million bytes for a window, a button and a pop-up?
Shouldn't this fit into 5-10 mb? Is the whole qt lib linked into that binary?
The demo application works without any of the libs from the deploy folder, but thats probably because it uses the system libs.
So cool:
- Option 1: 'go build' creates one large 50mb binary
- Option 2: 'qtdeploy' creates a bundle with a little more than whats required but you can remove what you dont need
- Option 3: just takes the binary and let the system provide the libs
Super cool would be, if that downsizing could be made automatically but since that icu stuff takes alone 24mb, that might be difficult. Anyway, great work. Spend half a day to get it working with system libs, but in the end I had to learn to just follow the tutorial and download qt again.
Great job :-)
I should probably mention that Option 1 is still depending on all the system/dynamic libs. And therefore only usefull to save time during development or if you need more control about the build. If you want to get a smaller binary, run `qtminimal` and `go build/run -tags=minimal` to include only the necessary C++ code, but the binary will still depend on the dynamic/system libs. I will add full statically linking in the future, but probably only after Qt 5.8 is released.
I've wanted to try this one out, but it looks like I'm maybe trying something too far off from mainstream. I like how the bindings can be built against incomplete Qt releases (iow. just the development packages available in debian sid); the build complains when some modules can't be found but continues nonetheless. Sure, it takes QT_DIR and PKG_CONFIG settings to build like this but I have no problem there.
So far I haven't found a way to build even the sample project against this type of custom build though. I'll try to find more time to dive in as to why this happens but I'm sure this is an error on my end. Once I figure that out, I should be able to provide a documentation update.
As to why? I have an old project which I need to revive, and being stuck in ancient GTK land with dubious bindings and even more dubious upstream practices sounds less appealing than porting things over.
But I think I found out at least one thing that goes wrong. I'll provide a github issue report later this weekend but here's the short version:
* The generated #cgo directives for CXXFLAGS are different for desktop and minimal files. Minimal is generated with -I$(QT_INCLUDE_DIR)/QtFoo include paths; desktop is generated with -I$(QT_DIR)/<major.minor>/gcc_64/include/QtFoo paths instead. So headers in desktop build are looked up from library directory paths (and with obviously bad path elements too).
* When building, qtsetup goes for desktop target.
More data coming in via github once I get the exact details sorted out.
But the qtsetup won't always re-generate these cgo_* files if the QT_DIR is up to date (there is probably a bug if you use QT_PKG_CONFIG).
So I would use `qtminimal` or `qtdeploy` for debugging this, because the minimal_cgo_* files are always re-generate.
And you may also want to change `InfoLevel` in `internal/utils/logger.go` to `DebugLevel` and then re-build the cmd/tools to get additional infos.
Hope this helps :)
It looks like a tiny Windows 95 on your phone. Tap targets way too small.
[1] https://itunes.apple.com/de/app/auto-motor-und-sport/id36644... [2] https://itunes.apple.com/us/app/mens-health-fitness-trainer/...
These days I use XFCE with http://www.noobslab.com/2016/03/vivacious-colors-gtk-theme-s... and it's nice.
This fragmentation is frustrating sometimes, but in the end what counts is whether the framework has solutions to your problems, and it usually does. (Meanwhile, Qt Quick is improving on the desktop over time.)
I was much more productive and I had much better integration with the respective OS APIs.
Granted, I wish I didn't have to use JS with it, but QML itself is fantastic.
I personally much prefer QtQuick to QtWidgets, and really like the QML declarative language as a better HTML/CSS for non-web. But I completely agree with you that I would prefer if I could code all my logic in C++ and not JS.
I've been meaning to play around with two ideas:
1. Construct the QtQick widget scenegraph wholly from C++ (and not using QML/JS at all). Doable, but definitely not intended usecase.
2. Construct the scenegraph using QML, but using it only for setting values (and never any logic) and then manually connecting the signals from the QML-created widgets to C++ slots.
Even more so if you're running on iOS where the JS isn't jitted.
It's really easy to write QObjects that are accessible to QML and you can connect your signals/slots with the QML widget ones, so having the logic in C++ isn't hard. It's just not quite as convenient as putting it inline in QML, I guess.
They're easy to use, themeable and hardware accelerated.
This is not really helpful, and destroys any chance at meaningful discussion.
(Also, last time you told me that rate limiting couldn’t be undone, and I should just write an email – what’s that about now?)
We detached this comment from https://news.ycombinator.com/item?id=12932238 and marked it off-topic.