Bizarre bug with Qt programs under WSL2 on Win 11

Damon Lynch damonlynch at gmail.com
Fri Nov 5 18:41:50 GMT 2021


Hi there,

It's not PyQt specific. Use Ctrl-Q to quit from a Qt program, and it's as
if the same key combo is pressed when you start any Qt program again, i.e.
the program quits instantly. Start another or the same Qt program, and it's
as if the q key is being pressed down on the keyboard (even though it's
not). It's so strange I made a video to illustrate:

https://youtu.be/MflcrMMlNnc

Tested under Ubuntu 20.04 & 21.10, with distro Qt packages and with the
PyQt5 pip package. Same result. Qt6 not tested. Non Qt programs seem
unaffected.

This is the same code if you want to try it yourself (or just start qt
assistant or similar):

import pkg_resources
import platform
import sys
from PyQt5.QtWidgets import QApplication, QTextEdit, QMainWindow,
QAction, QToolBar
from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR
from PyQt5.QtGui import QTextCursor


class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        self.textEdit = QTextEdit()
        self.setCentralWidget(self.textEdit)
        self.setWindowTitle("Catch Input Example")
        self.setMinimumWidth(500)
        self.toolbar = QToolBar("Catch Input Toolbar")
        self.addToolBar(self.toolbar)
        self.quitAct = QAction("&Quit", self, shortcut="Ctrl+Q",
triggered=self.close)
        self.toolbar.addAction(self.quitAct)
        location = (
            pkg_resources.get_distribution("PyQt5").location
        )
        self.textEdit.setText(
            f"Platform: {platform.platform()}\n"
            f"PyQt: {PYQT_VERSION_STR}\n"
            f"Qt: {QT_VERSION_STR}\n"
            f"PyQt5 location: {location}\n"
        )
        self.textEdit.moveCursor(QTextCursor.End)
        self.move(10, 10)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()

    window.show()
    sys.exit(app.exec_())


-- 
https://damonlynch.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211105/ae89c89d/attachment.htm>


More information about the PyQt mailing list