Expose any Qt5 program via VNC

raymii.org
5 min read
fairly easy
Article URL: https://raymii.org/s/articles/Expose_any_QT_program_via_VNC.html Comments URL: https://news.ycombinator.com/item?id=28597870 Points: 1 # Comments: 0
Published: 20-09-2021 | Author: Remy van Elst | Text only version of this article

Remote Coffee Machine Qt GUI via VNC

A few months ago I wrote about Microsoft Teams running on a coffee machine. That was a fun work experiment where I got a VNC client running on the linux-based coffee machines that we produce at work. In the comments on hackernews Jean-Michaël Celerier pointed me to the reverse, a way to expose any Qt application over VNC. This article shows you how I use this feature to work on our Qt 5 based coffee machine frontend as well as how you can use this on your machine, for example, to expose Dolphin, the KDE file manager, over VNC.

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.

Our Qt frontend for the coffee machines can run as a local application just fine, it's nothing more than a client towards an HTTP API. One other such client is our touchless feature, that exposes a part of the machine over MQtT to a website.

One issue with running the Qt application on my workstation is that remote media is not loaded. The coffee machine can display images and video (and show a QR code), but those images are dynamically loaded in QML, via a filesystem path that my machine does not have. I could setup an sshfs mount, but that would require fiddling with permissions. In the instances that I have to work on that part of the code I run the UI via VNC directly on a coffee machine, all the filesystem paths are available then.

Qt 5 applications via VNC

You can append a command line flag to any Qt application or set an environment variable to expose the application over VNC. The command line flag is -platform vnc and the environment variable is Qt_QPA_PLATFORM="vnc" . Here is how to run Dolphin via VNC on port 5900:

Qt_QPA_PLATFORM="vnc" dolphin # or dolphin -platform…
Read full article