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

后端 未结 7 1520
一向
一向 2020-12-09 12:05

I need to do this for configuring my application. I have QLineEdit field with reimplemented keyPressEvent method.

QKeyEvent *ke = ...
QString txt;

if(ke->         


        
7条回答
  •  悲&欢浪女
    2020-12-09 12:30

    simpliest way is:

    if(event->type() == QEvent::KeyPress)
    {
        QKeyEvent *keyEvent = static_cast(event);
        qDebug() << "delete" << keyEvent->matches(QKeySequence::Delete);
        qDebug() << "copy" << keyEvent->matches(QKeySequence::Copy);
        qDebug() << "paste" << keyEvent->matches(QKeySequence::Paste);
    }
    

提交回复
热议问题