C++ (Qt)qApp->installEventFilter( this );
C++ (Qt)QKeyEvent *keyEvent = qobject_cast <QKeyEvent *>(event);
C++ (Qt)//обработка прерываний клавиатурыbool Widget::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) // /*&& obj->objectName() == "Имя виджета"*/) { static int i; if (i != 0) {i = 0; return QObject::eventFilter(obj, event);} QKeyEvent *keyEvent = static_cast <QKeyEvent *>(event); i = keyEvent->key(); if ((i > 47) && (i < 58) ) fnDigit(i - 48); //цифры if (i == 43) fnAction(1); //+ if (i == 45) fnAction(2); //- if (i == 42) fnAction(3); //* if (i == 47) fnAction(4); /// if (i == 16777220) Widget::MyEventHandler3(); //Enter if (i == 16777221) Widget::MyEventHandler3(); //Enter if (i == 16777216) Widget::MyEventHandler4(); //Esc = C if (i == 16777232) Widget::MyEventHandler4(); //Home = C if (i == 16777233) Widget::MyEventHandler5(); //End = SE if (i == 16777238) Widget::MyEventHandler6(); //PgUp = Sqrt if (i == 16777239) Widget::MyEventHandler7(); //PgDn = % if (i == 16777249) Widget::MyEventHandler9(); //Ctrl = +/- if (i == 46) Widget::MyEventHandler8(); //"." //тут можно посмотреть коды клавиш //ui->lineEdit->setText(QString::number(i)); } return QObject::eventFilter(obj, event); }