Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QKeySequence::Backspace

In Qt, QKeySequence::Delete corresponds to deleteForward: message in MacOS.

What is the Qt equivalent of deleteBackward: from MacOS? If there is no such thing, how to capture the deleteBackward: event in Qt?

Qt documentation on key sequences does not mention this: http://qt-project.org/doc/qt-5.0/qtgui/qkeysequence.html

like image 800
Ecir Hana Avatar asked May 19 '26 09:05

Ecir Hana


1 Answers

QKeySequence has a constructor that takes key codes:

QKeySequence::QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0)

For deleteBackward: you would use the Qt::Key_Backspace key code. If you for example whish to create a shortcut for a QAction object:

myAction->setShortcut(QKeySequence(Qt::Key_Backspace));

or simply:

myAction->setShortcut(Qt::Key_Backspace);
like image 159
Daniel Hedberg Avatar answered May 22 '26 02:05

Daniel Hedberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!