14

I try to run some Qt application in a docker container by mounting /tmp/.X11-unix. I saw here that can be difficult.

So when I run kdevelop in a docker container, it does not work (I get an empty window). But if I run qtcreator it's fine.

I think the difference is because of the Qt version used (kdevelop is developed with Qt4 and qtcreator with Qt5). All my other Qt5 applications work fine, but not a single Qt4 application.

Question:

Does anyone know what to do to launch a Qt4 application, without going a long way round like with vnc or ssh, just like this:

docker run -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix someQt4AppContainer

?

yanana
  • 2,241
  • 2
  • 18
  • 28
jmc
  • 173
  • 1
  • 2
  • 8

2 Answers2

14

Qt5 and Qt4 has a different rendering subsystems

Qt4 renderer just needs a hint:

export QT_GRAPHICSSYSTEM="native"

This must be work

QT_GRAPHICSSYSTEM="native" docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix someQt4AppContainer
  • 2
    Thanks a lot. It's work fine. But you have to export QT_GRAPHICSSYSTEM="native" in the container. And you can run application qt4 and qt5 as well. – jmc Jan 27 '16 at 14:48
  • I had to do both this and set QT_X11_NO_MITSHM as described here: https://stackoverflow.com/a/55989420/543720 – Jeroen Vlek May 09 '19 at 09:48
1

Try with :

export QT_QPA_PLATFORM=offscreen

This will make the shell variable visible to programs invoked from this shell.

Bob Dalgleish
  • 8,167
  • 4
  • 32
  • 42
  • Unfortunatly I'm getting this error `qt.qpa.plugin: Could not find the Qt platform plugin "offscreen" in ""` when attempting to run openscad – spuder Dec 26 '21 at 05:28