C++ (Qt) QKeyEvent *upperKeyEvent = new QKeyEvent(QEvent::KeyPress, keyEvent->nativeVirtualKey(), Qt::NoModifier, QChar(keyEvent->nativeVirtualKey())); qDebug() << upperKeyEvent->text(); QApplication::postEvent(target, upperKeyEvent);
C++ (Qt)QKeyEvent ke (QEvent::KeyPress, keyEvent->nativeVirtualKey(), Qt::NoModifier, QChar(keyEvent->nativeVirtualKey()));event = &ke;return QWidget::eventFilter(target, event);
C++ (Qt) QString objName = target->objectName(); if(objName == "TestEdit") { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if((keyEvent->modifiers() & Qt::ControlModifier) || (keyEvent->modifiers() & Qt::AltModifier)) return true; QKeyEvent ke = QKeyEvent(QEvent::KeyPress, keyEvent->nativeVirtualKey(), Qt::NoModifier, QChar(keyEvent->nativeVirtualKey())); event = &ke; qDebug() << ke.text(); // Вот тут большими буквами пишется return QWidget::eventFilter(target, event); } } return QWidget::eventFilter(target, event);
C++ (Qt)event = &ke;
C++ (Qt)*event = ke;
C++ (Qt)*keyEvent = ke;
C++ (Qt)bool EntryWindow::eventFilter(QObject *target, QEvent *event){ QString objName = target->objectName(); if(objName == "TestEdit") { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if((keyEvent->modifiers() & Qt::ControlModifier) || (keyEvent->modifiers() & Qt::AltModifier)) return true; QKeyEvent ke = QKeyEvent(QEvent::KeyPress, keyEvent->nativeVirtualKey(), Qt::NoModifier, QChar(keyEvent->nativeVirtualKey())); *keyEvent = ke; qDebug() << ke.text(); return QWidget::eventFilter(target, keyEvent); } } return QWidget::eventFilter(target, event);}