Hacker News new | ask | show | jobs
by mappu 2979 days ago
Note that Qt has two separate technology previews for porting Qt apps to run in the web browser:

Qt WebGL streaming (qplatform/qpa plugin):

The Qt binary runs on your PC as normal, but instead of opening an X11/Win32 window, opens a network port. You can open the URL in a browser to see the interface. Only one connection is allowed / only one user can interact with the app at a time.

Technology preview since 5.10, will be "TP2" status in 5.11. See http://blog.qt.io/blog/2017/11/14/qt-webgl-cinematic-experie... and http://blog.qt.io/blog/2017/07/07/qt-webgl-streaming-merged/

Qt for WebAssembly:

The entire QtWidgets / QML libraries are compiled to WASM and run clientside. There is no server-side component.

Will be released as a technology preview in the upcoming 5.11 release.

3 comments

> The Qt binary runs on your PC as normal, but instead of opening an X11/Win32 window, opens a network port. You can open the URL in a browser to see the interface.

GTK 3 has something like that, too. Tried it once; super weird seeing Nautilus inside a browser. Cool, but weird.

> GTK 3 has something like that, too.

Yeah. It's called Broadway. If someone wish to give a try, see https://developer.gnome.org/gtk3/stable/gtk-broadway.html

They should port the rendering of the qt components to Dom/css with a web assembly backend. That would seem like a web app but allow for c++ code reuse.
I think that would be more feasible with something like wxWidgets or libui [0], which already use each platform's native widgets.

[0] https://github.com/andlabs/libui

GTK isn't native on a huge number of users' desktops, including mine. It wouldn't be so bad if the GTK CADTs would stop breaking style configuration with each release.
I don't think it's doable on a Dom/css in a meaningful way as the semantics are too different.

But a webgl canvas id doable and I think what they are aiming for. Which would be great for QML.

Having used QML in the past, its made the most sense to me out of all the UI/Animation setups I have ever used. This sounds amazing
I've used it a fair bit and it gets very messy very quickly. It pretty much encourages spaghetti code.

Also it is very incomplete. For example there's no way to do custom widgets that draw text (e.g. a graph). There's no good text area widget (there is one but it is extremely limited - you couldn't use it for a log output for example).

Plain QtWidgets is way way better on every level except animation and styling. And maybe touch support.

But if I were making a mobile app I'd definitely use Flutter. Much nicer experience than QML.

It definitely can get messy, but there are some very easy ways to keep your project well structured.

1. Refactor out to separate components a lot.

2. Use the .ui.qml and .qml code behind pattern to separate UI from code.

3. Use singleton QtObjects to create abstract classes that contain any non-UX behavior.

As for graphing, the built in components work pretty well:

https://doc.qt.io/qt-5.10/qtcharts-index.html

As far as QML widgets go, they have improved greatly since they released Quick Controls 2 (a rewrite of the initial set of controls).

https://doc.qt.io/qt-5.10/qtquickcontrols2-index.html

Unlike most of Qt, QtCharts is GPL, not LGPL. You can't avoid the virality by dynamic linking.