Qt4.7.0添加自定义键盘(KeyBoard)

上传人:人*** 文档编号:511574997 上传时间:2023-09-13 格式:DOC 页数:5 大小:32KB
返回 下载 相关 举报
Qt4.7.0添加自定义键盘(KeyBoard)_第1页
第1页 / 共5页
Qt4.7.0添加自定义键盘(KeyBoard)_第2页
第2页 / 共5页
Qt4.7.0添加自定义键盘(KeyBoard)_第3页
第3页 / 共5页
Qt4.7.0添加自定义键盘(KeyBoard)_第4页
第4页 / 共5页
Qt4.7.0添加自定义键盘(KeyBoard)_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《Qt4.7.0添加自定义键盘(KeyBoard)》由会员分享,可在线阅读,更多相关《Qt4.7.0添加自定义键盘(KeyBoard)(5页珍藏版)》请在金锄头文库上搜索。

1、http:/ 10:50:57|分类: 默认分类 |标签: |字号大中小订阅 一、在qt-4.7.0-arm/src/gui/embedded下新建qkbdmy_qws.h#include #ifndef QT_NO_QWS_KBD_MYclass QWSMyKbPrivate;class QWSMyKeyboardHandler : public QWSKeyboardHandlerpublic: QWSMyKeyboardHandler(const QString &); virtual QWSMyKeyboardHandler();private: QWSMyKbPrivate *d;#

2、endif / QT_NO_QWS_KBD_MY二、在qt-4.7.0-arm/src/gui/embedded下新建qkbdmy_qws.cpp#include qkbdmy_qws.h#ifndef QT_NO_QWS_KBD_MY#include #include #include #include #include #include #include #include #include class QWSMyKbPrivate : public QObject Q_OBJECTpublic: QWSMyKbPrivate(QWSMyKeyboardHandler *handler, c

3、onst QString &device); QWSMyKbPrivate(); bool isOpen() return buttonFD 0; private Q_SLOTS: void readKeyboardData();private: QWSMyKeyboardHandler *m_handler; QString terminalName; int buttonFD; int kbdIdx; int kbdBufferLen; unsigned char *kbdBuffer; QSocketNotifier *notifier;QWSMyKeyboardHandler:QWSM

4、yKeyboardHandler(const QString &device) : QWSKeyboardHandler(device) d = new QWSMyKbPrivate(this, device);QWSMyKeyboardHandler:QWSMyKeyboardHandler() delete d;QWSMyKbPrivate:QWSMyKbPrivate(QWSMyKeyboardHandler *h, const QString &device) : m_handler(h) terminalName = device.isEmpty()?/dev/mykeyboard:

5、device.toLatin1(); buttonFD = -1; notifier = 0; if (buttonFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY) = 0 ) notifier = new QSocketNotifier( buttonFD, QSocketNotifier:Read, this ); connect( notifier, SIGNAL(activated(int),this,SLOT(readKeyboardData() ); kbdBufferLen = 80; k

6、bdBuffer = new unsigned char kbdBufferLen; kbdIdx = 0;QWSMyKbPrivate: QWSMyKbPrivate() if ( buttonFD 0 ) :close( buttonFD ); buttonFD = -1; delete notifier; notifier = 0; delete kbdBuffer;void QWSMyKbPrivate:readKeyboardData() int n = 0; int idx = 0; n = read(buttonFD, kbdBuffer+kbdIdx, 4); unsigned

7、 char *next = kbdBuffer + idx; int *code = (int *)next; int keycode = Qt:Key_unknown; switch ( (*code) & 0xff ) case 1: keycode = Qt:Key_Left; break; case 2: keycode = Qt:Key_Right; break; case 3: keycode = Qt:Key_Up; break; case 4: keycode = Qt:Key_Down; break; case 15: keycode = Qt:Key_cent; break

8、; default: qDebug(Unrecognised key code %d, *code ); m_handler-processKeyEvent( 0, keycode, 0, TRUE, FALSE );#include qkbdmy_qws.moc#endif / QT_NO_QWS_KBD_MY三、打开qt-4.7.0-arm/src/gui/embedded下的qkbddriverfactory_qws.cpp添加代码如下#include qapplication.h/added by Tang-#include qkbdmy_qws.h/-#include qkbdtty

9、_qws.h QString driver = key.toLower();/added by Tang-#ifndef QT_NO_QWS_KBD_MY if (driver = QLatin1String(my) | driver.isEmpty() return new QWSMyKeyboardHandler(device);#endif/-#if defined(Q_OS_QNX) & !defined(QT_NO_QWS_KBD_QNX) if (driver = QLatin1String(qnx) | driver.isEmpty() return new QWSQnxKeyboardHandler(device);#endif QStringList list;/added by Tang-#ifndef QT_NO_QWS_KBD_MY list QLatin1String(MY);#endif/-#if defined(Q_OS_QNX) & !defined(QT_NO_QWS_KBD_QNX) list QLatin1String(QNX);#endif四、打开qt-4.7.0-arm/src/gui/embedded下的embedde

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 小学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号