forked from hanxiaoluo/KeyboardLiuDianWu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
49 lines (42 loc) · 1.44 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
46
47
48
49
#include "frmmain.h"
#include <QApplication>
#include "qtextcodec.h"
#include "qfile.h"
#include "frminput.h"
#include "frmnum.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
//QT5版本以上默认就是采用UTF-8编码
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
#endif
qApp->setFont(QFont("Microsoft YaHei", 9));
#ifndef __arm__
//如果输入法字库文件不存在,自动拷贝字库文件
QString path = qApp->applicationDirPath();
QFile file(path + "/py.db");
if (!file.exists() || file.size()==0) {
QStringList list = path.split("/");
QString fileName, newName;
for (int i = 0; i < list.count() - 2; i++) {
fileName = fileName + list.at(i) + "/";
}
fileName += "InputTool/py.db";
newName = path + "/py.db";
file.remove();
QFile::copy(fileName, newName);
}
#endif
//在main函数中就加载输入法面板,保证整个应用程序可以使用输入法
//以下方法打开中文输入法
frmInput::Instance()->Init("control", "silvery", 10, 10);
//以下方法打开数字键盘
//frmNum::Instance()->Init("black", 10);
frmMain w;
w.showMaximized();
return a.exec();
}