当前位置:网站首页>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();
}
边栏推荐
- Stm32-hal library learning, using cubemx to generate program framework
- SCM is now overwhelming, a wide variety, so that developers are overwhelmed
- My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
- 内存数据库究竟是如何发挥内存优势的?
- El table X-axis direction (horizontal) scroll bar slides to the right by default
- openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
- Mysql database underlying foundation column
- 嵌入式本来就很坑,相对于互联网来说那个坑多得简直是难走
- Getting started with JMX, MBean, mxbean, mbeanserver
- (2)接口中新增的方法
猜你喜欢
There is no specific definition of embedded system
03 fastjason solves circular references
Pymssql controls SQL for Chinese queries
2. Elment UI date selector formatting problem
STM32 external interrupt experiment
My notes on intelligent charging pile development (II): overview of system hardware circuit design
Quelle langue choisir pour programmer un micro - ordinateur à puce unique
Mobile phones are a kind of MCU, but the hardware it uses is not 51 chip
Yocto technology sharing phase IV: customize and add software package support
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
随机推荐
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
Oracle database SQL statement execution plan, statement tracking and optimization instance
The third paper of information system project manager in soft examination
Education is a pass and ticket. With it, you can step into a higher-level environment
万字手撕七大排序(代码+动图演示)
Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)
Schematic diagram and connection method of six pin self-locking switch
学习开发没有捷径,也几乎不存在带路会学的快一些的情况
Idea remote breakpoint debugging jar package project
Project scope management__ Scope management plan and scope specification
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
Yocto Technology Sharing Phase 4: Custom add package support
2. Elment UI date selector formatting problem
STM32 general timer 1s delay to realize LED flashing
LeetCode - 673. 最长递增子序列的个数
Development of intelligent charging pile (I): overview of the overall design of the system
手机都算是单片机的一种,只不过它用的硬件不是51的芯片
byte alignment