On Qt6, main window fails to show after being hidden, if run without window manager
-
wrote on 4 May 2022, 22:15 last edited by
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 -
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 -
wrote on 5 May 2022, 13:39 last edited by
@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.) -
wrote on 5 May 2022, 14:52 last edited by
try to call this first setWindowFlag( Qt::WindowStaysOnTopHint ); before it is set visible. It is likely that some other widget is set to the top. This widget is behind it.
-
wrote on 6 May 2022, 11:52 last edited by
@JoeCFD the code above only creates one widget, and the display is used only by one application. But-- I tried that (in Python, it became
m.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint)
), with no effect. Might this be a bug? -
wrote on 6 May 2022, 13:51 last edited by
you may create a small test case to replicate the issue. The people here will be able to help you out.
-
wrote on 6 May 2022, 21:57 last edited by squirrel 5 Jun 2022, 21:58
@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.
2/7