标题:QT自定义按键
作者:kkkxcy
日期:2011-08-09 21:24
内容:
最近几天在网上搜索一下关于QtE自定义按键的文章,看了有些收获,拿出来大家讨论讨论
公司是通过串口接的键盘,通过串口接键盘首先要有串口驱动,设置串口(波动率,数据位,停止位,数据怎样校验)
--------------------------test.h------------------------------------------------------
#ifndef TEST_H
#define TEST_H
class test :public QWidget
{
Q_OBJECT
public :
test();
int fd;
QSocketNotifier *notifier;
public slots:
void readKeyboardData();
};
#endif
------------------------------test.cpp------------------------------
#include /*标准输入输出定义*/
#include /*标准函数库定义*/
#include /*Unix 标准函数定义*/
#include
#include
#include /*文件控制定义*/
#include /*PPSIX 终端控制定义*/
#include /*错误号定义*/
#include "test.h"struct termios opt;
test::test()
{
fd=-1;
fd=open("/dev/ttyS0",O_RDONLY | O_NDELAY);
// 设置串口属性
cfsetispeed(&opt, B9600);
cfsetospeed(&opt, B9600);
opt.c_cflag |=CLOCAL | CREAD;
  ..
#1 回 楼主(kkkxcy) 的帖子 [wxj120bw 08-11 00:34]
是通过数字键1~4来发送按键的向上,向下,向左,向右四个事件吧。
#2 [kkkxcy 08-11 20:28]
是的