Attention

You are viewing an older version of the documentation. The latest version is v3.3.

Microservice: Qt 5 Examples

The following section describes how to integrate a containerized set of Qt 5 examples. These instructions assume an existing ECI installation and familiarity with building Docker containers.

Building: Qt Container

The following section is applicable to:

../../_images/linux4.png

The following steps detail how to build a Docker image which contains Qt 5 examples.

  1. If not already completed, follow section Prepare the Build System for Microservices to prepare the build system.

  2. Open a terminal on the build system and navigate to the extracted Dockerfiles directory. The contents of this directory should be as follows:

    $ ls
    application-containers  bpf  display-containers  softplc-containers
    
  3. Navigate to the display-containers directory. The contents of this directory should be as follows:

    $ ls
    display-server-weston  display-server-xorg  qt5-examples
    
  4. Navigate to the qt5-examples directory. The contents of this directory should be as follows:

    $ ls
    Dockerfile  README.md
    
  5. Build the Qt 5 examples container by performing the following command:

    $ docker build -t qt5-examples:v1.5 .
    

    Note

    The “.” at the end of the command is intentional.

  6. Save the Docker image as a tar archive by performing the following command:

    $ docker save -o qt5-examples.tar qt5-examples:v1.5
    

    After the save has completed successfully, there will be a tarballed Docker image:

    Docker Image archive name

    Description of Docker Image

    qt5-examples.tar

    Docker image which contains a set of Qt 5 examples.

Executing: Qt Container

The following section is applicable to:

../../_images/target5.png
  1. Ensure that the Docker daemon is active. Run the following command to restart the Docker daemon.

    Warning

    All running Docker containers will also restart.

    $ systemctl restart docker
    

    The status of the Docker daemon can be verified with the following command:

    $ systemctl status docker
    
  2. Copy the Docker image created earlier to the target system.

  3. Load the copied Docker image by performing the following command:

    $ docker load < qt5-examples.tar
    
  4. Check which Docker images are present on the target system with the following command:

    $ docker images
    

    The Firefox web browser image that was loaded should be present in the list. Note the name and tag of the image for use in the following steps.

    For example, on our system the output is as follows:

    $ docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
    qt5-examples        v1.5                0f7a21745b8d        About a minute ago   543MB
    
  5. This container provides the source for the Qt5 examples as well as one prebuilt example which is run automatically when the container starts. Qt will communicate with the display server through a file socket under /tmp, this is why /tmp is mounted into this container with -v /tmp:/tmp. The DISPLAY variable must be set accordingly, for example to :0 for the first display.

    --device /dev/dri allows access to the GPU through the DRI interface as Linux device.

    Run the container by performing the following command:

    $ docker run -d --rm \
      --name qt5-examples \
      --device /dev/dri \
      -v /tmp:/tmp \
      -e DISPLAY=:0 \
      qt5-examples
    

A new window will show the Qt5 example 40000 Chips.

../../_images/microservice_qt5-examples_40000-chips.png