问题描述
void LoginModle::keyPressEvent(QKeyEvent *event)
{
qDebug() << event->key() << "\t" << Qt::Key_Enter << "\t" << QKeyEvent::Enter;
if( event->key() == Qt::Key_Enter)
OKButtonClicked();
else
QDialog::keyPressEvent(event);
}
这段代码非常简单,类LoginModle
从QWidget
继承.运行此代码,当我按时,它将显示:
This code is very simple, class LoginModle
inherits from QWidget
. run this code and when I press , it shows:
16777220 16777221 10
这意味着我在键盘上的是16777220
,但是在Qt中,它被定义为16777221
.
It means that my in keyboard is 16777220
, but in Qt, it was defined as 16777221
.
我的系统是基于Ubuntu 14.04的Elementary OS(Freya).
My system is Elementary OS (Freya), which is based on Ubuntu 14.04.
我的驱动程序是否有问题或只是程序的错误?
Is there something wrong with my driver or just the program's mistake ?
推荐答案
16777220(dec)= 1000004(hex),因此根据此列表,按下的键是返回".查看 Wiki -Enter键在数字键盘中,您使用的键在Qt中称为返回键".
16777220(dec) = 1000004(hex), so according to this list, pressed key is "Return". Look at the Wiki - Enter key is in numeric keypad, key used by you is called in Qt "Return key".
这篇关于Qt键Pressevent输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!