Make Desktop Qt 5 application run with mir-kiosk on Ubuntu Core

I managed to build a snap of my Qt5/ QML user interface application which works on Ubuntu Desktop. I’m using the snapcraft-desktop-helpers according to these instructions. However, my goal is to run the user interface on Ubuntu Core connected to a touchscreen. I figured out that I need to use mir-kiosk and followed mainly Part 13 of the instructions.

However, I’m not sure how these two helpers are intended to work together - if at all. I’m assuming that the mir-kiosk-snap-launch is not configuring anything with the Qt5 dependencies. But on the other side the desktop-helpers are not setting anything with the wayland Mir interface.

Is mir-kiosk-snap-launch even intended to set the necessary Qt configurations/ paths? Or how should I proceed?

This is my snapcraft.yaml:

name: test
base: core18 
version: '0.2' 
summary: The Software 
description: |
  This snap includes the software to operate the high-level
  control PC.

grade: devel
confinement: devmode

    command: wayland-launch roslaunch nav_gui gui.launch

    command: wayland-launch bin/desktop-launch roslaunch nav_gui gui.launch

    command: bin/desktop-launch roslaunch nav_gui gui.launch

    command: bin/desktop-launch wayland-launch roslaunch nav_gui gui.launch

    command: run-daemon wayland-launch roslaunch nav_gui gui.launch
    daemon: simple
    restart-condition: always

    command: rostopic

    command: rosservice



    source-subdir: qt
    plugin: make
    make-parameters: ["FLAVOR=qt5"]
      - build-essential
      - qtbase5-dev
      - qt5-default
      - libqt5quick5
      - qtdeclarative5-dev
      - qtquickcontrols2-5-dev
      - qtmultimedia5-dev
      - dpkg-dev
      - libqt5qml5
      - libqt5quick5
      - libqt5quickcontrols2-5
      - libqt5quicktemplates2-5
      - qml-module-qtquick-layouts
      - qml-module-qtquick-controls
      - qml-module-qtquick-controls2
      - qml-module-qtmultimedia
      - qml-module-qtquick-extras
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libqt5gui5
      - libgdk-pixbuf2.0-0
      - libqt5svg5 # for loading icon themes which are svg
      - try: [appmenu-qt5] # not available on core18
      - locales-all
      - xdg-user-dirs
      - fcitx-frontend-qt5

    plugin: catkin-tools
    source: .
    rosinstall-files: [snap/local/snap.rosinstall]
    recursive-rosinstall: true
    catkin-packages: [catkin_simple, nav_gui]
    build-packages: [git]
    after: [desktop-qt5]

    plugin: dump
    override-build:  $SNAPCRAFT_PART_BUILD/ wayland

Reduced to the relevant parts of the errors, this is what I get in the different situations with this snapcraft.yaml:

  • bin/desktop-launch works on Ubuntu Desktop, but on Core for obvious reasons:
qt.qpa.screen: QXcbConnection: Could not connect to display 
Could not connect to any X display.
  • wayland-launch on Core:
+ [ ! -O /run/user/1000/wayland-0 ]
+ echo waiting for Wayland socket
waiting for Wayland socket
  • run-daemon wayland-launch on Core:
Jan 09 15:32:37 localhost test.daemon[10788]: This application failed to start because it could not find or load the Qt platform plugin "xcb"
Jan 09 15:32:37 localhost test.daemon[10788]: in "".
  • bin/desktop-launch wayland-launch on Core:
+ [ ! -O /run/user/1000/wayland-0 ]
+ echo waiting for Wayland socket
waiting for Wayland socket

Can you please point me in the right direction?

This is the tutorial I’m actually linking and following in my post.

Btw, running glmark2-wayland as shown in the example works fine.

The /run/user/1000/wayland-0 indicates you are not running the snap as a daemon as described in the tutorial.

That’s not going to work without a mir-kiosk running as the same user (which is tricky on Core).

What errors are shown by:

snap logs -n 100 test

I need to clarify: I was only running run-daemon wayland-launch roslaunch nav_gui gui.launch as a daemon, which resulted in:

This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".

I had this error before, when I didn’t use the desktop-qt5 helpers. This is why I’m wondering how I include Qt5 correctly again, when using mir-kiosk-snap-launch.

The other commands are run1 to run4 from the snapcraft.yaml apps, which I executed “manually”. So I assume executing them manually is never a good idea.

OK. That problem is because Qt is trying to find the X11 backend and failing. You don’t want the X11 backend (which Qt calls “xcb”), you want the wayland backend.

Here’s an example that configures Qt to run as a kiosk:

1 Like

You could probably run them as root (i.e. with sudo).

Thanks, I will try this. Do I even need the desktop-qt5 from the desktop helpers or should I just copy the dependencies and leave the desktop-launch out?

In the end I just need it as a daemon. I thought it would simplify things when running it not as a daemon first (was reading this in another tutorial). But in this case, I will not do this anymore.

You probably don’t need desktop helpers to get Qt to work, it was developed to help with desktop integration and isn’t well adapted to non-desktop. Good luck!

1 Like

So thanks to your example application, I got my Qt user interface running without any problems. I tried to strip down the code as much as possible. But I still lack some understanding for the following things:

  1. From my last snapcraft.yaml, I have many Qt5 build- and stage-packages included. But in the example I just see 4 Qt-related stage-packages. I assume this is because the examples are already pre-built and that’s why I still need them, right?

  2. The snappy-qt5.conf file points to these stage- and build-packages, right?

  3. The text in my UI when built with snapcraft appears different than before. For example, it doesn’t fit on buttons anymore. Why is this?

  4. Before, we discussed about always using mir-kiosk apps as daemon. But in the example snapcraft.yaml, there is still this mir-kiosk-apps entry. Why?

  5. I don’t have anything about opengl or mesa in my snapcraft.yaml. Do I even need these?

Parts that stage packages installed from .debs automatically bring the corresponding dependencies into the snap.

That’s what it looks like, there are several ways to do this.

I don’t know. I suspect you may have picked up a style/theme from your desktop environment that affects typeface or size.

That isn’t required. It allows the snap to be run directly on the desktop, which is convenient for testing.

Yes, they are not provided by the core snap. But you may be getting them pulled into your snap by something else you stage, in which case you don’t need to mention them explicitly.


$ apt depends qtwayland5
  Depends: libc6 (>= 2.14)
  Depends: libegl1
  Depends: libgcc1 (>= 1:3.4)
  Depends: libgl1
  Depends: libqt5core5a (>= 5.9.5+dfsg~)
  Depends: libqt5gui5 (>= 5.9.5+dfsg~)
  Depends: libqt5waylandclient5 (>= 5.9.2)
  Depends: libqt5waylandcompositor5 (>= 5.9.0~rc)
  Depends: libstdc++6 (>= 5)
  Depends: libwayland-client0 (>= 1.9.91)
 |Depends: libwayland-egl1-mesa (>= 10.0.2)
  Depends: libwayland-egl1
  Depends: libwayland-server0 (>= 1.6.0)
  Depends: libx11-6
  Depends: libxcomposite1 (>= 1:0.3-1)
  Depends: <qtbase-abi-5-9-5>
1 Like