Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt app UI elements randomly rendered as blank/black in Docker

Tags:

c++

docker

qt

I prepared Dockerfile to build Docker image of my Qt application. To run the application I use X - I enable access to X server (xhost +local:root), then I use the following command to run it:

docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" mindforger:latest mindforger

The problem is that some Qt UI elements (menu items, dialogs, ...) are rendered blank in black (randomly) - check the screenshot below:

enter image description here

I'm on Ubuntu 16.04.5 with Docker 18.06 and Qt 5.01.

like image 652
Martin Dvorak Avatar asked Sep 25 '18 15:09

Martin Dvorak


People also ask

How do I skip Qt deployment in Docker?

As long as Qt doesn’t change, you can skip the Qt deployment. Go to the build settings Projects > Build & Run > Docker Qt 5.14.1 > Build, set the variable DEPLOY_QT to OFF in the CMake section and press the Apply Configuration Changes button. Your workflow is now the same as if you were running the application on your development PC.

How do I use qtcreator with Docker CMake lists?

If you open the project file /public/Work/qtcreator-with-docker/CMakeLists.txt for the first time, QtCreator asks you to configure the project (see next screenshot). Select the kit Docker Qt 5.14.1 you just created and press the Configure Project button.

How do I build a docker image from a QEMU file?

By running docker buildx build --platform linux/arm/v7 -t arm-buil d . This command builds the docker image as per the `Dockerfile` in the current directory using ARMv7 emulation. Behind the scenes, Docker runs the whole Docker build process in a QEMU virtualized environment ( qemu-user-static to be precise).

How to build and deploy an application in Qt?

You build, deploy and run the application by pressing Ctrl+R in Qt Creator. And then – you can try out your change on the target system. You get immediate feedback how your change behaves on the target system.


1 Answers

I had the same problem, and I couldn't solve it formally. But we found an alternative workaround to not display the error:

In our case, we have four QComboBoxes in a window. Our problem was that after starting the app, the second (sometimes the first) combo box you clicked displayed a black popup. So what we did was initializing the window with two dummy combo boxes, calling the showPopup method, and then hiding both the popups and the combo boxes. So the user can't notice the error. I hope you can make something similar with your app.

like image 52
maxi.marufo Avatar answered Nov 15 '22 01:11

maxi.marufo