简体   繁体   中英

What are QKeyEvent.nativeModifiers()?

What are QKeyEvent.nativeModifiers()? The documentation doesn't say much ( https://doc.qt.io/qtforpython/PySide6/QtGui/QKeyEvent.html#PySide6.QtGui.PySide6.QtGui.QKeyEvent.nativeModifiers ). From what I understand, the integer that is returned by calling this method on a QKeyEvent object represents the full state of the modifier keys (Ctrl, Shift, Alt, etc.).

Moreover, I would assume that the mapping between these integers and their respective modifier states is systematic, so is there a way to test whether a given modifier state contains a specific modifier (eg by using the "&" operator)?

Importantly, are the native modifiers cross-platform such that a Left Ctrl keypress on a PC returns the same integer as a Left Command on a Mac (since Qt.Key_Control corresponds to the MacOS command keys)?

As name suggests native modifiers has different values on mac and on pc. On windows value is a combination of WindowsNativeModifiers , on macOS it is a combination of NSEventModifierFlags , both translated to Qt::KeyboardModifiers ( windows macOS ) which is same on both platforms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM