当前位置:网站首页>QT detection card reader analog keyboard input
QT detection card reader analog keyboard input
2022-07-03 10:02:00 【Master Hao】
bool GiveBackCard2::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent event = static_cast<QKeyEvent>(ev);
int iKey = event->key();
if(iKey == Qt::Key_Return || iKey == Qt::Key_Enter) // Enter to send the stored information
{
if(!_outerCardID.isEmpty())
{
if(_outerCardID==_cardID)
{
_canGiveBack=true;
setTipLabel(QString::fromLocal8Bit(“ The match is successful ”));
}
else
{
_canGiveBack=false;
setTipLabel(QString::fromLocal8Bit(“ Matching failure ”));
}
}
return true;
}
else if(0 <= iKey && 128 > iKey) // Character key values can be displayed
{
// Judge the time interval from the last valid key , Greater than 200ms Reset input storage , Otherwise, accumulate the recorded characters
int iElapsed = m_tmWatch.msecsTo(QTime::currentTime());
//qDebug() << iElapsed << iKey;
if(200 < iElapsed)
{
_outerCardID = event->text();
}
else
{
_outerCardID += event->text();
}
m_tmWatch = QTime::currentTime();
}
}
return false;
}
When with Qt::Tool when , The window has no focus by default , Need to use code to control activation .
this->setWindowFlags(Qt::FramelessWindowHint|Qt::Tool);
Be careful , Card reader input requires manual activation of the window interface :
int GiveBackCard2::exec()
{
show();
activateWindow();
return QDialog::exec();
}
边栏推荐
- My 4G smart charging pile gateway design and development related articles
- STM32 general timer 1s delay to realize LED flashing
- 我想各位朋友都应该知道学习的基本规律就是:从易到难
- 自動裝箱與拆箱了解嗎?原理是什麼?
- 4G module IMEI of charging pile design
- Stm32f04 clock configuration
- Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
- 要選擇那種語言為單片機編寫程序呢
- 03 fastjason solves circular references
- Working mode of 80C51 Serial Port
猜你喜欢

JS基础-原型原型链和宏任务/微任务/事件机制

手机都算是单片机的一种,只不过它用的硬件不是51的芯片

SCM career development: those who can continue to do it have become great people. If they can't endure it, they will resign or change their careers

Notes on C language learning of migrant workers majoring in electronic information engineering

单片机职业发展:能做下去的都成牛人了,熬不动就辞职或者改行了

一个可执行的二进制文件包含的不仅仅是机器指令

要選擇那種語言為單片機編寫程序呢

Happy Dragon Boat Festival—— Zongzi written by canvas~~~~~

当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
![[untitled] proteus simulation of traffic lights based on 89C51 Single Chip Microcomputer](/img/90/4de927e797ec9c2bb70e507392bed0.jpg)
[untitled] proteus simulation of traffic lights based on 89C51 Single Chip Microcomputer
随机推荐
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
It is difficult to quantify the extent to which a single-chip computer can find a job
Liquid crystal display
STM32 serial communication principle
自動裝箱與拆箱了解嗎?原理是什麼?
Emballage automatique et déballage compris? Quel est le principe?
我想各位朋友都应该知道学习的基本规律就是:从易到难
Notes on C language learning of migrant workers majoring in electronic information engineering
MySQL 数据库基础知识(系统化一篇入门)
STM32 interrupt priority management
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
Screen display of charging pile design -- led driver ta6932
Stm32f04 clock configuration
JS foundation - prototype prototype chain and macro task / micro task / event mechanism
没有多少人能够最终把自己的兴趣带到大学毕业上
2020-08-23
Swing transformer details-2
Which language should I choose to program for single chip microcomputer
Application of external interrupts
Stm32 NVIC interrupt priority management