Qt 软键盘设计
最近有客户用的电脑是触屏的,所以不用键盘与鼠标,系统的键盘不好看,所以自己设计一个键盘显示,先看下效果图;
设计思路,构建一个软键盘设计界面并重写输入框,然后做界面提升,直接上代码
class CustomLineEdit : public QLineEdit
{
Q_OBJECT
public:
CustomLineEdit(QWidget *parent = Q_NULLPTR);
~CustomLineEdit();
protected:
bool eventFilter(QObject* sender, QEvent* event);
};
CustomLineEdit::CustomLineEdit(QWidget *parent)
: QLineEdit(parent)
{
installEventFilter(this);
}
CustomLineEdit::~CustomLineEdit()
{
}
bool CustomLineEdit::eventFilter(QObject* sender, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress)
{
if (!ClientLogic::GetKeyboardStatus())
{
SystemParams sysParams;
ClientLogic::GetSystemParams(sysParams);
if (sysParams.m_bSoftKeyboard)
{
ClientLogic::SetKeyboardStatus(true);
auto pSoftKeyBoard = ivmsClient::getInstance()->GetSoftKeyBoard();
if (pSoftKeyBoard)
{
pSoftKeyBoard->show();
}
/* DialogSoftKeyBoard dlgKeyBoard;
dlgKeyBoard.exec();*/
}
}
}
return QLineEdit::eventFilter(sender, event);
}
#ifndef DialogSoftKeyBoard_h__
#define DialogSoftKeyBoard_h__
#include <QDialog>
#include <QVector>
#include <QLabel>
#include <QMap>
#include <QMouseEvent>
#include <QListWidgetItem>
#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class DialogSoftKeyBoard;
};
class DialogSoftKeyBoard : public QDialog
{
Q_OBJECT
public:
DialogSoftKeyBoard(QWidget *parent = Q_NULLPTR);
~DialogSoftKeyBoard();
protected:
/// 鼠标事件重写
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
private slots:
void slotKeyButtonClicked();
void slotKeyLetterButtonClicked();
void slotKeyNumberButtonClicked();
void on_listWidget_itemClicked(QListWidgetItem *item);
void on_toolButton_lastPage_clicked();
void on_toolButton_nextPage_clicked();
void on_ButtonClose_clicked();
private:
void initFrm();
void loadChineseFontData();
void findChineseFontData(QString text);
void addOneItem(QString text);
QString OnLoadQssStyle(const QString& filePath, const QString& fileName);
private:
Ui::DialogSoftKeyBoard *ui;
QMap<QString, QList<QPair<QString, QString>>> m_data;
bool m_bIsChinese = false;
QString m_recordLitterBuf;
QVector<QPushButton*> m_letterKeys;
QVector<QPushButton*> m_NumberKeys;
QMap<QString, Qt::Key> m_mapSymbolKeys;
QStringList m_showTextList;
int m_curPage = 0;
QLabel* m_labelShowPinyin;
Qt::KeyboardModifier m_curModifier = Qt::NoModifier;
bool m_bPressed = false;
QPoint m_ptPressStart = { 0, 0 };
};
#endif // DialogSoftKeyBoard_h__
#include "DialogSoftKeyBoard.h"
#include "ui_DialogSoftKeyBoard.h"
#include <QPushButton>
#include <QKeyEvent>
#include <QDebug>
#include <QStyle>
#include <QListWidgetItem>
#include <QLabel>
#include <QVBoxLayout>
#include <QToolTip>
#include "ClientLogic.h"
DialogSoftKeyBoard::DialogSoftKeyBoard(QWidget *parent)
: QDialog(parent)
{
ui = new Ui::DialogSoftKeyBoard();
ui->setupUi(this);
setWindowTitle("键盘");
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_TranslucentBackground);
ui->listWidget->setEnabled(false);
initFrm();
loadChineseFontData();
QString DirPathStr = QCoreApplication::applicationDirPath();
QString qssPath = DirPathStr + "/Clientqss";
QString qssFile = OnLoadQssStyle(qssPath, "/DialogSoftKeyBoard.qss");
this->setStyleSheet(qssFile);
ui->frame->installEventFilter(this);
ui->listWidget->installEventFilter(this);
}
DialogSoftKeyBoard::~DialogSoftKeyBoard()
{
ClientLogic::SetKeyboardStatus(false);
delete ui;
}
void DialogSoftKeyBoard::mouseMoveEvent(QMouseEvent *event)
{
if (m_bPressed)
{
auto gEndPos = event->globalPos();
this->move(pos() + (gEndPos - m_ptPressStart));
m_ptPressStart = gEndPos;
}
event->ignore();
}
void DialogSoftKeyBoard::mousePressEvent(QMouseEvent *event)
{
auto gPos = event->globalPos();
auto gLeftTop = this->frameGeometry().topLeft();
if (event->button() == Qt::LeftButton &&
ui->listWidget->frameRect().contains(gPos - gLeftTop))
{
m_bPressed = true;
m_ptPressStart = gPos;
}
event->ignore();
}
void DialogSoftKeyBoard::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_bPressed = false;
}
event->ignore();
}
QString DialogSoftKeyBoard::OnLoadQssStyle(const QString& filePath, const QString& fileName)
{
QString qssFile = "";
QFile file(filePath + fileName);
file.open(QFile::ReadOnly);
if (file.isOpen())
{
qssFile = QString::fromLocal8Bit(file.readAll());
file.close();
}
return qssFile;
}
void DialogSoftKeyBoard::slotKeyButtonClicked()
{
QPushButton* pbtn = (QPushButton*)sender();
QString objectName = pbtn->objectName();
if (pbtn->text().contains("BACKSPACE"))
{
if (m_bIsChinese){
if (m_recordLitterBuf.size() > 0)
{
m_recordLitterBuf.remove(m_recordLitterBuf.size() - 1, 1);
findChineseFontData(m_recordLitterBuf);
if (!m_labelShowPinyin->text().isEmpty())
m_labelShowPinyin->setText(m_recordLitterBuf);
}
else
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Backspace, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Backspace, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Backspace, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Backspace, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else if (pbtn->text().contains("CAPS"))
{
if (pbtn->isChecked())
{
for (auto pbtnKey : m_letterKeys)
{
pbtnKey->setText(pbtnKey->text().toUpper());
}
}
else
{
for (auto pbtnKey : m_letterKeys)
{
pbtnKey->setText(pbtnKey->text().toLower());
}
}
}
else if (pbtn->text() == "SPACE")
{
if (!isActiveWindow())
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Space, m_curModifier, " ");
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Space, m_curModifier, " ");
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else if (pbtn->text().contains("TAB"))
{
//QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, m_curModifier);
//QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Tab, m_curModifier);
//QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
//QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (pbtn->text().contains("ENTER"))
{
if (!isActiveWindow())
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Enter, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Enter, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else if (pbtn->text().contains("SHIFT"))
{
if (pbtn->isChecked()) {
m_bIsChinese = true;
m_curModifier = Qt::ShiftModifier;
ui->listWidget->setEnabled(true);
/*for (auto pbtnKey : m_letterKeys) {
pbtnKey->setText(pbtnKey->text().toUpper());
}*/
}
else
{
ui->listWidget->setEnabled(false);
m_bIsChinese = false;
ui->listWidget->clear();
m_showTextList.clear();
m_curPage = 0;
m_labelShowPinyin->clear();
m_recordLitterBuf.clear();
m_curModifier = Qt::NoModifier;
for (auto pbtnKey : m_letterKeys)
{
pbtnKey->setText(pbtnKey->text().toLower());
}
}
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Shift, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Shift, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (pbtn->text().contains("CTRL"))
{
if (pbtn->isChecked())
m_curModifier = Qt::ControlModifier;
else
m_curModifier = Qt::NoModifier;
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Control, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Control, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (pbtn->text().contains("WIN"))
{
if (pbtn->isChecked())
m_curModifier = Qt::MetaModifier;
else
m_curModifier = Qt::NoModifier;
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Meta, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Meta, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (pbtn->text().contains("ALT"))
{
if (pbtn->isChecked())
m_curModifier = Qt::AltModifier;
else
m_curModifier = Qt::NoModifier;
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Alt, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Alt, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if(objectName == "ButtonTop")// (pbtn->text().contains("↑"))
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Up, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Up, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (objectName == "ButtonBottom") //(pbtn->text().contains("↓"))
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Down, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Down, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (objectName == "ButtonLeft") //(pbtn->text().contains("←"))
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Left, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Left, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (objectName == "ButtonRight") //(pbtn->text().contains("→"))
{
QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Right, m_curModifier);
QKeyEvent keyRelease(QEvent::KeyRelease, Qt::Key_Right, m_curModifier);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
else if (objectName == "ButtonClose")
{
ClientLogic::SetKeyboardStatus(false);
done(QDialog::Accepted);
}
else
{
QString symbol;
if (ui->Button_shift->isChecked())
symbol = pbtn->text().split("\n").at(0);
else
symbol = pbtn->text().split("\n").at(1);
QKeyEvent keyPress(QEvent::KeyPress, m_mapSymbolKeys.value(symbol), m_curModifier, symbol);
QKeyEvent keyRelease(QEvent::KeyRelease, m_mapSymbolKeys.value(symbol), m_curModifier, symbol);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
void DialogSoftKeyBoard::slotKeyLetterButtonClicked()
{
QPushButton* pbtn = (QPushButton*)sender();
if (*(pbtn->text().data()) >= 'a' && *(pbtn->text().data()) <= 'z')
{
if (m_bIsChinese)
{
m_recordLitterBuf += pbtn->text().toLower();
findChineseFontData(m_recordLitterBuf);
}
else
{
ui->listWidget->clear();
m_showTextList.clear();
m_curPage = 0;
m_labelShowPinyin->clear();
m_recordLitterBuf.clear();
QKeyEvent keyPress(QEvent::KeyPress, int(pbtn->text().at(0).toLatin1()) - 32, m_curModifier, pbtn->text());
QKeyEvent keyRelease(QEvent::KeyRelease, int(pbtn->text().at(0).toLatin1()) - 32, m_curModifier, pbtn->text());
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else if (*(pbtn->text().data()) >= 'A' && *(pbtn->text().data()) <= 'Z')
{
if (m_bIsChinese)
{
m_recordLitterBuf += pbtn->text().toLower();
findChineseFontData(m_recordLitterBuf);
}
else
{
ui->listWidget->clear();
m_showTextList.clear();
m_curPage = 0;
m_labelShowPinyin->clear();
m_recordLitterBuf.clear();
QKeyEvent keyPress(QEvent::KeyPress, int(pbtn->text().at(0).toLatin1()), m_curModifier, pbtn->text());
QKeyEvent keyRelease(QEvent::KeyRelease, int(pbtn->text().at(0).toLatin1()), m_curModifier, pbtn->text());
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
//取消组合键按下
// if (ui.pushButton_shift->isChecked()) {
// ui.pushButton_shift->setChecked(false);
// for (auto pbtnKey : m_letterKeys) {
// pbtnKey->setText(pbtnKey->text().toLower());
// }
// }
if (ui->Button_ctrl->isChecked())
ui->Button_ctrl->setChecked(false);
if (ui->Button_win->isChecked())
ui->Button_win->setChecked(false);
if (ui->Button_alt->isChecked())
ui->Button_alt->setChecked(false);
m_curModifier = Qt::NoModifier;
}
void DialogSoftKeyBoard::slotKeyNumberButtonClicked()
{
QPushButton* pbtn = (QPushButton*)sender();
int num = pbtn->text().toInt();
if (m_bIsChinese)
{
if (m_recordLitterBuf.size() > 0)
{
if (num > 0 && num <= 9 && ui->listWidget->count() >= num)
{
on_listWidget_itemClicked(ui->listWidget->item(num - 1));
}
}
else
{
QKeyEvent keyPress(QEvent::KeyPress, num + 48, m_curModifier, pbtn->text());
QKeyEvent keyRelease(QEvent::KeyRelease, num + 48, m_curModifier, pbtn->text());
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
else
{
QKeyEvent keyPress(QEvent::KeyPress, num + 48, m_curModifier, pbtn->text());
QKeyEvent keyRelease(QEvent::KeyRelease, num + 48, m_curModifier, pbtn->text());
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
//取消组合键按下
// if (ui.pushButton_shift->isChecked()) {
// ui.pushButton_shift->setChecked(false);
// for (auto pbtnKey : m_letterKeys) {
// pbtnKey->setText(pbtnKey->text().toLower());
// }
// }
if (ui->Button_ctrl->isChecked())
ui->Button_ctrl->setChecked(false);
if (ui->Button_win->isChecked())
ui->Button_win->setChecked(false);
if (ui->Button_alt->isChecked())
ui->Button_alt->setChecked(false);
}
m_curModifier = Qt::NoModifier;
}
void DialogSoftKeyBoard::on_listWidget_itemClicked(QListWidgetItem *item)
{
QKeyEvent keyPress(QEvent::KeyPress, 0, m_curModifier, item->text().right(1));
QKeyEvent keyRelease(QEvent::KeyRelease, 0, m_curModifier, item->text().right(1));
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
ui->listWidget->clear();
m_showTextList.clear();
m_curPage = 0;
m_labelShowPinyin->clear();
m_recordLitterBuf.clear();
}
void DialogSoftKeyBoard::on_toolButton_lastPage_clicked()
{
if (m_curPage <= 0)
return;
m_curPage--;
ui->listWidget->clear();
for (int i = m_curPage * 9; i < m_curPage * 9 + 9; i++)
{
if (i >= m_showTextList.count())
break;
addOneItem(m_showTextList.at(i));
}
}
void DialogSoftKeyBoard::on_toolButton_nextPage_clicked()
{
if (m_curPage >= m_showTextList.count() / 9)
return;
m_curPage++;
ui->listWidget->clear();
for (int i = m_curPage * 9; i < m_curPage * 9 + 9; i++)
{
if (i >= m_showTextList.count())
break;
addOneItem(m_showTextList.at(i));
}
}
void DialogSoftKeyBoard::on_ButtonClose_clicked()
{
ClientLogic::SetKeyboardStatus(false);
done(QDialog::Accepted);
}
void DialogSoftKeyBoard::initFrm()
{
m_letterKeys.clear();
m_NumberKeys.clear();
QList<QPushButton*> pbtns = this->findChildren<QPushButton*>();
foreach(QPushButton * pbtn, pbtns)
{
pbtn->setAutoRepeat(true); //允许自动重复
pbtn->setAutoRepeatDelay(500);//设置重复操作的时延
if (*(pbtn->text().data()) >= 'a' && *(pbtn->text().data()) <= 'z')
{
connect(pbtn, &QPushButton::clicked, this, &DialogSoftKeyBoard::slotKeyLetterButtonClicked);
m_letterKeys.push_back(pbtn);
}
else if (pbtn->text().toInt() > 0 && pbtn->text().toInt() <= 9 || pbtn->text() == "0")
{
connect(pbtn, &QPushButton::clicked, this, &DialogSoftKeyBoard::slotKeyNumberButtonClicked);
m_NumberKeys.push_back(pbtn);
}
else
{
connect(pbtn, &QPushButton::clicked, this, &DialogSoftKeyBoard::slotKeyButtonClicked);
}
}
m_labelShowPinyin = new QLabel();
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addWidget(m_labelShowPinyin);
vLayout->addStretch();
ui->listWidget->setLayout(vLayout);
m_mapSymbolKeys.insert("~", Qt::Key_AsciiTilde);
m_mapSymbolKeys.insert("`", Qt::Key_nobreakspace);
m_mapSymbolKeys.insert("-", Qt::Key_Minus);
m_mapSymbolKeys.insert("_", Qt::Key_Underscore);
m_mapSymbolKeys.insert("+", Qt::Key_Plus);
m_mapSymbolKeys.insert("=", Qt::Key_Equal);
m_mapSymbolKeys.insert(",", Qt::Key_Comma);
m_mapSymbolKeys.insert(".", Qt::Key_Period);
m_mapSymbolKeys.insert("/", Qt::Key_Slash);
m_mapSymbolKeys.insert("<", Qt::Key_Less);
m_mapSymbolKeys.insert(">", Qt::Key_Greater);
m_mapSymbolKeys.insert("?", Qt::Key_Question);
m_mapSymbolKeys.insert("[", Qt::Key_BracketLeft);
m_mapSymbolKeys.insert("]", Qt::Key_BracketRight);
m_mapSymbolKeys.insert("{", Qt::Key_BraceLeft);
m_mapSymbolKeys.insert("}", Qt::Key_BraceRight);
m_mapSymbolKeys.insert("|", Qt::Key_Bar);
m_mapSymbolKeys.insert("\\", Qt::Key_Backslash);
m_mapSymbolKeys.insert(":", Qt::Key_Colon);
m_mapSymbolKeys.insert(";", Qt::Key_Semicolon);
m_mapSymbolKeys.insert("\"", Qt::Key_QuoteLeft);
m_mapSymbolKeys.insert("'", Qt::Key_Apostrophe);
}
void DialogSoftKeyBoard::loadChineseFontData()
{
QString exePath = QCoreApplication::applicationDirPath();
exePath += "/PinYin_Chinese.txt";
QFile pinyin(exePath);
if (!pinyin.open(QIODevice::ReadOnly))
{
qDebug() << "Open pinyin file failed!";
return;
}
while (!pinyin.atEnd())
{
QString buf = QString::fromUtf8(pinyin.readLine()).trimmed();
if (buf.isEmpty())
continue;
/* 去除#号后的注释内容 */
if (buf.left(1) == "#")
continue;
buf = buf.replace("\t", " ");
QString pinyin = buf.mid(1, buf.size() - 1);
QString word = buf.mid(0, 1);
QString abb;
QStringList pinyinList = pinyin.split(" ");
for (int i = 0; i < pinyinList.count(); i++) {
/* 获得拼音词组的首字母(用于缩写匹配) */
abb += pinyinList.at(i).left(1);
}
QList<QPair<QString, QString>> &tmp = m_data[pinyin.left(1)];
/* 将'拼音(缩写)'和'词组'写入匹配容器 */
tmp.append(qMakePair(abb, word));
/* 将'拼音(全拼)'和'词组'写入匹配容器 */
tmp.append(qMakePair(pinyin.remove(" "), word));
}
qDebug() << m_data.size();
pinyin.close();
}
void DialogSoftKeyBoard::findChineseFontData(QString text)
{
QString lowerText = text.toLower();
m_labelShowPinyin->setText(lowerText);
for (int i = 0; i < ui->listWidget->count(); i++)
{
QListWidgetItem *item = ui->listWidget->takeItem(i);
delete item;
item = NULL;
}
ui->listWidget->clear();
m_showTextList.clear();
m_curPage = 0;
if (lowerText.count() <= 0)
return;
const QList<QPair<QString, QString> > &tmp = m_data[lowerText.left(1)];
bool fond = false;
for (int i = 0; i < tmp.count(); i++)
{
const QPair<QString, QString> &each = tmp.at(i);
if (each.first.left(lowerText.count()) != lowerText)
continue;
fond = true;
addOneItem(each.second);
m_showTextList.push_back(each.second);
}
if (!fond)
{
if (m_recordLitterBuf.count() > 1)
{
m_recordLitterBuf = m_recordLitterBuf.right(1);
findChineseFontData(m_recordLitterBuf);
}
else
{
QKeyEvent keyPress(QEvent::KeyPress, int(m_recordLitterBuf.at(0).toLatin1()), m_curModifier, m_recordLitterBuf);
QKeyEvent keyRelease(QEvent::KeyRelease, int(m_recordLitterBuf.at(0).toLatin1()), m_curModifier, m_recordLitterBuf);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyPress);
QApplication::sendEvent(qApp->focusWidget() == nullptr ? this : qApp->focusWidget(), &keyRelease);
}
}
}
void DialogSoftKeyBoard::addOneItem(QString text)
{
if (ui->listWidget->count() >= 9)
return;
QString itemText = QString("%1.%2").arg(ui->listWidget->count() + 1).arg(text);
QListWidgetItem *item = new QListWidgetItem(itemText);
QFont font;
font.setPointSize(15);
font.setBold(true);
font.setWeight(50);
item->setFont(font);
/* 设置文字居中 */
item->setTextAlignment(Qt::AlignBottom | Qt::AlignHCenter);
bool isChineseFlag = QRegExp("^[\u4E00-\u9FA5]+").indexIn(text.left(1)) != -1;
int width = font.pointSize();
if (isChineseFlag)
width += itemText.count()*font.pointSize()*1.5;
else
width += itemText.count()*font.pointSize() * 2 / 3;
item->setSizeHint(QSize(width, 50));
ui->listWidget->addItem(item);
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogSoftKeyBoard</class>
<widget class="QDialog" name="DialogSoftKeyBoard">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>878</width>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
<string>DialogSoftKeyBoard</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>0</width>
<height>320</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListWidget" name="listWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="minimumSize">
<size>
<width>80</width>
<height>73</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>73</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ButtonClose">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="toolButton_lastPage">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_nextPage">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="Button_fuhao">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>~
`</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_1">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_2">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_3">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_4">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_5">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_6">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_7">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_8">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_9">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_0">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_9">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>_
-</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_10">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>+
=</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_backspace">
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>BACKSPACE</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="Button_tab">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>TAB</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_Q">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>q</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_W">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>w</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_E">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>e</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_R">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>r</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_T">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>t</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_Y">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_U">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>u</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_I">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>i</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_O">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>o</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_P">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>p</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_1">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>{
[</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>}
]</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>|
\</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="Button_capsLock">
<property name="minimumSize">
<size>
<width>80</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>CAPS
LOCK</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_A">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>a</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_S">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>s</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_D">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>d</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_F">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>f</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_G">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>g</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_H">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>h</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_J">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>j</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_K">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>k</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_L">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>l</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>:
;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>"
'</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_enter">
<property name="minimumSize">
<size>
<width>120</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>ENTER</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="spacing">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="Button_shift">
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="toolTip">
<string>En/Ch</string>
</property>
<property name="text">
<string>SHIFT</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_Z">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_X">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_C">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>c</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_V">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>v</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_B">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>b</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_N">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_M">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>m</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string><
,</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_7">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>>
.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_8">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>?
/</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonTop">
<property name="minimumSize">
<size>
<width>163</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>163</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>↑</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<property name="spacing">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="Button_ctrl">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>CTRL</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_win">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>WIN</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_alt">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>ALT</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Button_space">
<property name="minimumSize">
<size>
<width>500</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>SPACE</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonLeft">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>←</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonBottom">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>↓</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonRight">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>→</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
好了,直接干吧!!