简体   繁体   中英

Propagate keyEvent from widget to QKeySequenceEdit

I have a QTreeWidget and QKeySequenceEdit and I want pressing shortcuts in QTreeWidget lead to editing shortcut in QKeySequenceEdit . I've installed eventFilter and constructed the corresponding QShortcut using this solution:

How can I capture QKeySequence from QKeyEvent depending on current keyboard layout?

But I'm stuck at sending event to QKeySequenceEdit . Here is a piece of code in eventFilter

qDebug()<<QKeySequence(keyInt).toString();
QShortcutEvent *shortcutEvent = new QShortcutEvent(QKeySequence(keyInt), QShortcut(QKeySequence(keyInt), this).id());
qApp->postEvent(ui->keySequenceEdit, shortcutEvent);
return true;

qDebug outputs right keys, but QKeySequenceEdit does not react.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM