[PyQt] keyPressEvent differences Qt4-Qt5 in Mac OS?

David Cortesi davecortesi at gmail.com
Fri Apr 4 14:49:59 BST 2014


In upgrading an app from Qt4 to Qt5 I have found what appears to be an
incompatibility between releases on Mac OS X.

The app intercepts keystrokes using a keyPressEvent method. In Qt4, when
the user presses the Mac keys Option and 3, the keyEvent contains a
modifier of Qt.Alt_Modifier and a key of Qt.Key_3 (0x33)

In Qt5, the modifier is the same, but the key is Qt.Key_sterling (0xa3).
Other Option-keys deliver, not the physical key code, but the special
characters shown in the Mac OS Keyboard Viewer widget. For example Option-7
delivers Qt.Key_paragraph instead of Key_7.

This could be seen as a feature for the Mac user, but it is a sharp
incompatibility between releases, and between platforms. It is not
mentioned in the PyQt5 diffs [1] or in the Qt5 transition doc [2]. I've
looked through the docs for QCoreApplication, QGuiApplication and
QApplication hoping for some kind of switch but don't see it.

I think this is probably in Qt5, but thought I'd ask if it could possibly
lie in PyQt5, or be circumvented in PyQt5.

Thanks for your attention,

Dave Cortesi

[1] http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html
[2] http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140404/e8b28c58/attachment.html>


More information about the PyQt mailing list