On Qt6, main window fails to show after being hidden, if run without window manager
-
Hello,
I am testing an addon to a Python Qt application (Anki) and I ran into a weird problem. Main window, if shown using
show()
, and hidden usinghide()
, will not draw whenshow()
is called again. Here's a minimal Python code that can reproduce the issue.from PyQt6.QtWidgets import QMainWindow, QApplication QApplication([]) m = QMainWindow() m.show() # this works, the window appears m.hide() # this also works, the window gets hidden m.show() # this does nothing
I am on Windows 10, and to see the above in action I run VcXsrv in the “One large window” mode, and then on WSL2 / Ubuntu I run
DISPLAY=$(ip route list default | awk '{print $3}'):0 python
and type the above. I also verified that the issue manifests when running with Xvfb, which is how I normally run tests, by callinggrabWindow()
.The issue does not manifest if running the same with Qt5, or if running the above code with VcXsrv in the “Multiple windows” mode.
Any ideas what might be causing this, and if there's a workaround?
Versions of things:
Windows 21H2 19044.1654
Ubuntu 20.04.4 LTS (WSL2)
Python 3.10.4
PyQt6 6.2.3, 6.3.0 — the issue exists in both
PyQt5 5.15.6 -
-
@jsulm I tried
raise()
and all possible combinations of methods that had the words such as show, activate, focus, etc in their name, that I could find. As far as I could tell, the window reports that it is not hidden, I can resize and move it, I cangrab()
it, in other words, it seems to behave like a very respectable window, except that it is not visible.(I am not at all well versed in Qt so I might have missed some (obvious) methods, but
raise()
I did try.) -
@JoeCFD the first post in this topic contains the code that's needed to replicate the issue. You'll need an X server without a window manager though; I have mentioned how I can get one on Windows but I'm not sure how exactly the setup can be replicated in Linux etc.