当前位置:网站首页>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();
}
边栏推荐
- Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
- Fundamentals of Electronic Technology (III)__ Chapter 6 combinational logic circuit
- Application of 51 single chip microcomputer timer
- STM32 interrupt switch
- 2020-08-23
- 2021-10-27
- 01 business structure of imitation station B project
- A lottery like scissors, stone and cloth (C language)
- There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
- 对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
猜你喜欢

03 fastjason solves circular references

Swing transformer details-1

51 MCU tmod and timer configuration

Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction

Swing transformer details-2

Education is a pass and ticket. With it, you can step into a higher-level environment

STM32 interrupt switch

Vector processor 9_ Basic multilevel interconnection network

yocto 技术分享第四期:自定义增加软件包支持

03 FastJson 解决循环引用
随机推荐
自动装箱与拆箱了解吗?原理是什么?
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
4G module designed by charging pile obtains signal strength and quality
01 business structure of imitation station B project
All processes of top ten management in project management
单片机学到什么程度能找到工作,这个标准不好量化
Oracle database SQL statement execution plan, statement tracking and optimization instance
STM32 general timer output PWM control steering gear
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
我想各位朋友都应该知道学习的基本规律就是:从易到难
使用密钥对的形式连接阿里云服务器
2021-10-28
You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
內存數據庫究竟是如何發揮內存優勢的?
SCM is now overwhelming, a wide variety, so that developers are overwhelmed
CEF download, compile project
Basic knowledge of MySQL database (an introduction to systematization)
Vscode markdown export PDF error
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
Development of intelligent charging pile (I): overview of the overall design of the system