-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Description
I'm trying to use qhotkey with my QuickApplication Project by Qt 6.8.2, but I found it can't register any key on macOS.
I try to run :
QHotkey hotkey(QKeySequence("Ctrl+Alt+Q"), true, &app); //The hotkey will be automatically registered
qDebug() << "Is registered:" << hotkey.isRegistered();
and running, console print:
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_Q Modifiers: QFlags<Qt::KeyboardModifier>(ControlModifier|AltModifier)
Is registered: false
than i write a function testMacOSHotkeys to try:
void testMacOSHotkeys() {
struct TestCase {
QString name;
QKeySequence sequence;
};
QVector<TestCase> tests = {
{"Meta+1", QKeySequence(Qt::META | Qt::Key_1)},
{"Meta+2", QKeySequence(Qt::META | Qt::Key_2)},
{"F1", QKeySequence(Qt::Key_F1)},
{"F2", QKeySequence(Qt::Key_F2)},
{"Meta+F1", QKeySequence(Qt::Key_F1 | Qt::META)},
{"Meta+A", QKeySequence(Qt::META| Qt::Key_A)},
{"Meta+S", QKeySequence(Qt::META | Qt::Key_S)},
{"Meta+D", QKeySequence(Qt::META | Qt::Key_D)},
{"Meta+W", QKeySequence(Qt::META | Qt::Key_W)},
{"Meta+X", QKeySequence(Qt::META | Qt::Key_X)},
{"Meta+Space", QKeySequence(Qt::META | Qt::Key_Space)},
{"Meta+Return", QKeySequence(Qt::META | Qt::Key_Return)},
{"Meta+Shift+A", QKeySequence(Qt::META | Qt::SHIFT | Qt::Key_A)},
{"Ctrl+Shift+A", QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_A)}
};
qDebug() << "========== Testing macOS Hotkey Support ==========";
int successCount = 0;
for (const auto& test : tests) {
QHotkey hotkey(test.sequence, true);
bool success = hotkey.isRegistered();
QString status = success ? " Supported" : " Not supported";
qDebug() << test.name.leftJustified(20) << ":" << status;
if (success) {
successCount++;
hotkey.setRegistered(false);
}
}
qDebug() << "==================================================";
qDebug() << "Success rate:" << successCount << "/" << tests.size();
qDebug() << "==================================================";
}
and there is the log:
========== Testing macOS Hotkey Support ==========
Device monitor thread started
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_1 Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+1 " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_2 Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+2 " : " Not supported"
"F1 " : " Supported"
"F2 " : " Supported"
"Meta+F1 " : " Supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_A Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+A " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_S Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+S " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_D Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+D " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_W Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+W " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_X Modifiers: QFlags<Qt::KeyboardModifier>(MetaModifier)
"Meta+X " : " Not supported"
"Meta+Space " : " Supported"
"Meta+Return " : " Supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_A Modifiers: QFlags<Qt::KeyboardModifier>(ShiftModifier|MetaModifier)
"Meta+Shift+A " : " Not supported"
QHotkey: Unable to map shortcut to native keys. Key: Qt::Key_A Modifiers: QFlags<Qt::KeyboardModifier>(ShiftModifier|ControlModifier)
"Ctrl+Shift+A " : " Not supported"
==================================================
Success rate: 5 / 14
==================================================
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels