QTest::sendKeyEvent(...Qt::ControlModifier)
causes a Command Key sent on Mac (and vice versa all QKeyEvents on Mac having Command pressed report the Qt::ControlModifier).
What I need to do in order to achieve a real Ctrl key sending ?
CodePudding user response:
Two solutions exists:
- Disable the mapping transformation:
QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
- Use the
Qt::MetaModifier
(Control key on mac is by default mapped toQt::MetaModifier
)
As mentioned in the docs, this mapping is normally expected by macOS users, as shortcuts are normally using the Command key instead of the Control (which is used on other platforms).