Kiosk Qt

I am building an image based on x86-64. The image is for an embedded system with touch screen and has a qt single application running. I know to create this I have to use kiosk mode. So, I am building a snap based on mir kiosk, wayland and Qt. I have already compiled a Qt application on another x86-64 machine and put it inside my snap. So far, Is this the only way to run the Qt in single app. mode? And how to add the touch screen libraries? Any guide would be helpful.

@alan_g, I followed this tutorial but used my Qt app instead. I already had it compiled on x86-64 ubuntu machine. And as my target is also x86-64 machine but based on ubuntu core, I used the ready-made binaries of my qt app. But I got the following error: Could not find the Qt platform plugin “xcb” in “”. To solve it, I added some stage-packages:
-qtwayland5
- libqt5waylandclient5
- libqt5waylandcompositor5
- libwayland-client0
- libwayland-egl1
- libwayland-server0
But the error is still here and I do not know what to do.

@abd_rahman it is a lot easier to help if you tell what you’ve done and tried and what errors you are seeing: Could not find the Qt platform plugin “xcb” in “”

I’m no expert on Qt, but “xcb” is the name for the X11 platform, which you don’t need. But to have Qt applications use Wayland (from qtwayland5) you need to set QT_QPA_PLATFORM to “wayland”. Something like:

environment:
  QT_QPA_PLATFORM: wayland

You may also need to set something like:

      QT_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/
      QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/platforms/

HTH

@alan_g , sorry for late reply:
here is my snapcraft.yml file:
name: qt1 # you probably want to 'snapcraft register ’
base: core18 # the base snap is the execution environment for this snap
version: ‘0.1’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: qt sample app # 79 char long summary
description:
qt sample kiosk app using wayland

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use sn'strict' once you have the right plugs and slots

apps:
  qt1:
    command: wayland-launch $SNAP/trial1 --fullscreen
    plugs:
    -  opengl
    -  wayland
    

  daemon:
    command: run-daemon wayland-launch $SNAP/trial1 --fullscreen
    daemon: simple
    restart-condition: always
    plugs:
    -  opengl
    -  wayland
    
    

environment:
  LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}:${SNAP}/usr/lib/:${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/
  PATH: $SNAP/bin/:$SNAP/usr/bin/:${PATH}
  # Prep EGL
  __EGL_VENDOR_LIBRARY_DIRS: $SNAP/etc/glvnd/egl_vendor.d:$SNAP/usr/share/glvnd/egl_vendor.d
  LIBGL_DRIVERS_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri
  LIBVA_DRIVERS_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri
  QT_QPA_PLATFORM: wayland
  QT_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/
  QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/platforms/
# QT_QPA_PLATFORMTHEME: gtk3 
parts:
  trial1:
    plugin: dump
    source: ./ha
    source-type: local
    stage-packages:
     - libdouble-conversion1
     - libfreetype6
     - libgraphite2-3
     - libharfbuzz0b
     - libicu60
     - libpng16-16
     - libqt5core5a
     - libqt5gui5
     - libqt5widgets5
     - qtwayland5
     - libqt5waylandclient5
     - libqt5waylandcompositor5
     - libwayland-client0
     - libwayland-egl1
     - libwayland-server0
     - libx11-6
     - qt5-default
    
  mesa:
    plugin: nil
    stage-packages:
      - libgl1-mesa-dri
      - libwayland-egl1-mesa
      - libglu1-mesa

  mir-kiosk-snap-launch:
    plugin: dump
    source: https://github.com/MirServer/mir-kiosk-snap-launch.git
    override-build:  $SNAPCRAFT_PART_BUILD/build-with-plugs.sh opengl wayland


#layout:
#  /usr/share:
#    bind: $SNAP/usr/share
#  /usr/share:
#    bind: $SNAP/usr/bin

And here is the new error after running it inside miral-kiosk&, snap run myapp:

  • snapctl is-connected wayland
  • dirname /run/user/1000/snap.qt1
  • real_xdg_runtime_dir=/run/user/1000
  • real_wayland=/run/user/1000/wayland-0
  • [ ! -O /run/user/1000/wayland-0 ]
  • mkdir -p /run/user/1000/snap.qt1 -m 700
  • ln -sf /run/user/1000/wayland-0 /run/user/1000/snap.qt1
  • ln -sf /run/user/1000/wayland-0.lock /run/user/1000/snap.qt1
  • unset DISPLAY
  • exec /snap/qt1/x22/trial1 --fullscreen
    QSocketNotifier: Can only be used with threads started with QThread
    Using Wayland-EGL
    Using the ‘xdg-shell-v6’ shell integration
    xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb
    Segmentation fault (core dumped)

Ok, your app is now connecting to Wayland. That is progress.

The error xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb is because snap confinement prevents access to the host filesystem. Issues like this are common when creating snaps and there are a range of solutions that ensure the code accesses files supplied by the snap.

In this case, mounting the snap filesystem in the place the code is looking is probably the simplest:

layout:
  /usr/share/X11/xkb:
    bind: $SNAP/usr/share/X11/xkb

But that does depend on the snap containing the right stuff.

@alan_g, It did run as in the screenshot: but the push button text or any text does not exist!

This was the output on the miral-kiosk& on my pc. I tried to scp the resulted snap onto my target platform. Then I installed it:
snap install --dangerous ./qt1_0.1_amd64.snap --devmode
I should expect it to run like the previous screenshot. but instead, I got nothing happened. So, I used:
snap run qt1
and got the following:
+ snapctl is-connected wayland
+ echo Wayland interface not connected!
Wayland interface not connected!
+ exit 1

This suggests that the wayland interface isn’t connected. You can check that with:

snap connections <snap name>

And fix it with:

snap connect <snap name>:wayland mir-kiosk:wayland

That sounds like it is not finding fonts. Are there any in the snap? Is Qt looking for them there?

My Qt app. is compiled on the host. So, should I add font packages in stage-packages?

That will ensure the fonts are available in the snap. You also need to ensure Qt can find them. (For example, if they are in $SNAP/usr/share/fonts and Qt looks in /usr/share/fonts that still won’t work.

I added:

 /usr/share/fonts:
        bind: $SNAP/usr/share/fonts

and it worked! I will try it on target and keep you posted.

1 Like