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:
I'm on Ubuntu 16.04.5 with Docker 18.06 and Qt 5.01.
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.
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With