#include "moveinput.h" #include "ui_moveinput.h" //#include #include "MyInputMethod.h" MoveInput::MoveInput(QWidget *parent) : QWidget(parent,(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool)), ui(new Ui::MoveInput) { ui->setupUi(this); connect(ui->Key_left,SIGNAL(pressed()),this,SLOT(onKeyLeftPressed())); connect(ui->Key_right,SIGNAL(pressed()),this,SLOT(onKeyRightPressed())); connect(ui->Key_up,SIGNAL(pressed()),this,SLOT(onKeyUpPressed())); connect(ui->Key_down,SIGNAL(pressed()),this,SLOT(onKeyDownPressed())); } MoveInput::~MoveInput() { delete ui; } void MoveInput::onKeyLeftPressed(){ #ifndef Q_OS_WIN32 //QWSServer::sendKeyEvent(0,Qt::Key_Left,Qt::NoModifier,true,false); //向系统发送键盘事件 MyInputMethod::sendEvent(Qt::Key_Left,Qt::NoModifier); #endif } void MoveInput::onKeyRightPressed(){ #ifndef Q_OS_WIN32 //QWSServer::sendKeyEvent(0,Qt::Key_Right,Qt::NoModifier,true,false); //向系统发送键盘事件 MyInputMethod::sendEvent(Qt::Key_Right,Qt::NoModifier); #endif } void MoveInput::onKeyUpPressed(){ #ifndef Q_OS_WIN32 //QWSServer::sendKeyEvent(0,Qt::Key_Up,Qt::NoModifier,true,false); //向系统发送键盘事件 MyInputMethod::sendEvent(Qt::Key_Up,Qt::NoModifier); #endif } void MoveInput::onKeyDownPressed(){ #ifndef Q_OS_WIN32 //QWSServer::sendKeyEvent(0,Qt::Key_Down,Qt::NoModifier,true,false); //向系统发送键盘事件 MyInputMethod::sendEvent(Qt::Key_Down,Qt::NoModifier); #endif }