Reputation: 1354
I'm working in a scientific calculator project using Qt5, I'm using the QTextEdit as the calculator's display. I want to disable the shortcuts like (Ctrl + A, and Ctrl + C) in the display, so How can I do that? Thank you.
Upvotes: 2
Views: 1934
Reputation: 875
Event filtering on the LineEdit is the proper way to do it, then you can ignore the ones you do not want or override the behavior.
A dirty shortcut (no pun intended) to try is to create a QShortcut and and assign it to an empty slot. Qt will probably complain about ambiguous shortcuts and will probably do not do anything with it. Dirty I know :)
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+A"), parent);
QObject::connect(shortcut, SIGNAL(activated()), receiver, SLOT(emptySlot()));
May be you can even ignore the connect part...
Upvotes: 1
Reputation: 186
Key Filter Method, Create an Event Filter that returns false for the Hot Keys. It's a little tedious, but should work out.
Upvotes: 2