Qt app UI elements randomly rendered as blank/blac

2020-06-20 16:11发布

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.

标签: c++ qt docker
4条回答
萌系小妹纸
2楼-- · 2020-06-20 16:32

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.

查看更多
走好不送
3楼-- · 2020-06-20 16:39

I had the same problem and found this solution which you have to run after starting the docker container. Once the specific docker container is started, run the following command within the docker container.

export QT_GRAPHICSSYSTEM="native"

Once this is pasted and executed within the docker terminal session, run the desired QT application and this black box problem should go away. You could even paste this option inside your docker's .bashrc if you didn't want to run it every time manually.

查看更多
贪生不怕死
4楼-- · 2020-06-20 16:42

In my case (Qt5 application) I resolved this by adding the param --shm-size 128M, mounting /dev/shm:/dev/shm should work too.

查看更多
叛逆
5楼-- · 2020-06-20 16:49

None of the posted solutions solved the identical problem that I encountered. However, this did fix it: QT_GRAPHICSSYSTEM=raster

查看更多
登录 后发表回答