QHotkey icon indicating copy to clipboard operation
QHotkey copied to clipboard

Registering the same shortcut twice prompts successful registration?

Open XMuli opened this issue 1 year ago • 1 comments

Thank you 😁, this is a great hotkey function repository, thanks for all your hard work. But I would like to ask a usage.


Supports multiple QHotkey-instances for the same shortcut (with optimisations)

How do I turn off this feature? I want the same shortcut to be registered only once (in the whole OS).


QHotkey* m_hkCapture = new QHotkey(QString("F1"), true, qApp);
QHotkey*  m_hkDelayCapture = new QHotkey(QString("F1"), true, qApp);
qDebug() << m_hkCapture << m_hkCapture->isRegistered() << m_hkCapture->shortcut().toString();
qDebug() << m_hkDelayCapture << m_hkDelayCapture->isRegistered() << m_hkCapture->shortcut().toString();

The results of the run are as follows, all registered successfully, unscientific; not the desired result. I debugged the relevant source code, but it's not very clear?

[debug] [main 50] QHotkey(0x288f22e10b0) true "F1" 
[debug] [main 51] QHotkey(0x288f22e08d0) true "F1" 

ENV:

Windows 10 22H2
Qt 5.15.2
CMake 3.27.0-rc4
MSVC 2022
X64 bit Debug & Release

XMuli avatar Sep 03 '24 17:09 XMuli

I am facing the same issue. Have you found any solution? Currently I am just keeping track of all the shortcuts I know, that are used by my application as well as the system (ctrl+c, ctrl+a, etc) and putting them in a blacklist. This library is very aggressive. If I add ctrl+c as a shortcut for a command, then it replaces the original copy command 🥲

DoonMad avatar Oct 22 '25 10:10 DoonMad