forked from xiaoyanLG/Soft-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
45 lines (39 loc) · 1.14 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <QApplication>
#include "xykeyboardfilter.h"
#include "xyvirtualkeyboard.h"
#include "xyskin.h"
#include <QIcon>
//#define TEST
#ifdef TEST
#include <QLineEdit>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QInputMethodEvent>
static void sendInputText(const QString &text)
{
QInputMethodEvent *event = new QInputMethodEvent;
event->setCommitString(text);
qApp->postEvent(qApp->focusWidget(), event);
}
#endif
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// XYSKIN->writeSkipToFile("I:/DeskTop/test.skin");
XYSKIN->loadSkipWithFile(qApp->applicationDirPath() + "/skin/xyinput.skin");
XYVirtualKeyboard::getInstance()->show();
#ifdef TEST
// 测试代码
QWidget widget;
QVBoxLayout *layout = new QVBoxLayout(&widget);
layout->addWidget(new QLineEdit);
layout->addWidget(new QTextEdit);
layout->addWidget(new QLineEdit);
widget.show();
QObject::connect(XYVirtualKeyboard::getInstance(), &XYVirtualKeyboard::send_commit, &sendInputText);
#endif
a.setQuitOnLastWindowClosed(true);
a.setWindowIcon(QIcon(":/Keyboard.ico"));
return a.exec();
}