From 73668611c69b9ca41870e1f20662ea0fc53e488a Mon Sep 17 00:00:00 2001 From: feiyangqingyun Date: Sun, 28 Nov 2021 11:16:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- other/echartgauge/main.cpp | 15 +++++++++++++++ other/lineeditnext/main.cpp | 15 +++++++++++++++ other/mouseline/main.cpp | 15 +++++++++++++++ third/hotkey/main.cpp | 15 +++++++++++++++ third/miniblink/main.cpp | 15 +++++++++++++++ third/miniblink/miniblink/miniblink.cpp | 17 +++++++++++++++-- third/qwtdemo/main.cpp | 18 +++++++++++++++++- third/shortcut/main.cpp | 15 +++++++++++++++ tool/keydemo/appkey.cpp | 1 + tool/keydemo/frmmain.cpp | 1 + tool/keydemo/main.cpp | 1 + tool/keytool/frmmain.cpp | 1 + tool/keytool/main.cpp | 1 + tool/livedemo/applive.cpp | 1 + tool/livedemo/main.cpp | 1 + tool/livetool/frmmain.cpp | 1 + tool/livetool/main.cpp | 1 + tool/moneytool/main.cpp | 15 +++++++++++++++ tool/moneytool/widget.cpp | 1 + 19 files changed, 147 insertions(+), 3 deletions(-) diff --git a/other/echartgauge/main.cpp b/other/echartgauge/main.cpp index c578744..4b2a476 100644 --- a/other/echartgauge/main.cpp +++ b/other/echartgauge/main.cpp @@ -2,12 +2,27 @@ #include "widget.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + Widget w; w.setWindowTitle("Echart图表JS交互示例 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/other/lineeditnext/main.cpp b/other/lineeditnext/main.cpp index 8c301cb..92dc79f 100644 --- a/other/lineeditnext/main.cpp +++ b/other/lineeditnext/main.cpp @@ -2,12 +2,27 @@ #include "widget.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + Widget w; w.setWindowTitle("回车自动跳转 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/other/mouseline/main.cpp b/other/mouseline/main.cpp index 352cfab..d88544c 100644 --- a/other/mouseline/main.cpp +++ b/other/mouseline/main.cpp @@ -2,12 +2,27 @@ #include "widget.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + Widget w; w.setWindowTitle("鼠标十字线 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/third/hotkey/main.cpp b/third/hotkey/main.cpp index bb76894..7264077 100644 --- a/third/hotkey/main.cpp +++ b/third/hotkey/main.cpp @@ -2,12 +2,27 @@ #include "frmhotkey.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + frmHotKey w; w.setWindowTitle("全局热键示例 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/third/miniblink/main.cpp b/third/miniblink/main.cpp index d0b28f6..352ad3e 100644 --- a/third/miniblink/main.cpp +++ b/third/miniblink/main.cpp @@ -2,12 +2,27 @@ #include "widget.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + Widget w; w.setWindowTitle("miniblink使用示例 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/third/miniblink/miniblink/miniblink.cpp b/third/miniblink/miniblink/miniblink.cpp index 5963133..adfdd35 100644 --- a/third/miniblink/miniblink/miniblink.cpp +++ b/third/miniblink/miniblink/miniblink.cpp @@ -1,8 +1,13 @@ -#include "miniblink.h" +#pragma execution_character_set("utf-8") +#include "miniblink.h" #include "qapplication.h" +#include "qmessagebox.h" +#include "qdatetime.h" +#include "qfile.h" #include "qvariant.h" #include "qdebug.h" +#define TIMEMS QTime::currentTime().toString("hh:mm:ss zzz") void onLoadingFinish(wkeWebView, void *param, const wkeString, wkeLoadingResult result, const wkeString) { //qDebug() << "onLoadingFinish" << result; @@ -56,14 +61,22 @@ void miniblink::init() isInit = true; //不同的构建套件位数加载不同的动态库 #ifdef Q_OS_WIN64 + QString flag = "64"; QString file = qApp->applicationDirPath() + "/miniblink_64.dll"; #else + QString flag = "32"; QString file = qApp->applicationDirPath() + "/miniblink.dll"; #endif + //如果文件不存在则提示 + if (!QFile(file).exists()) { + QMessageBox::critical(0, "错误", file + "\n文件不存在请先拷贝!"); + return; + } + const wchar_t *path = reinterpret_cast(file.utf16()); wkeSetWkeDllPath(path); bool ok = wkeInitialize(); - qDebug() << QString("init miniblink %1").arg(ok ? "ok" : "error"); + qDebug() << TIMEMS << QString("init miniblink_%1 %2").arg(flag).arg(ok ? "ok" : "error"); } } diff --git a/third/qwtdemo/main.cpp b/third/qwtdemo/main.cpp index 74bdaee..7cba000 100644 --- a/third/qwtdemo/main.cpp +++ b/third/qwtdemo/main.cpp @@ -1,11 +1,27 @@ #pragma execution_character_set("utf-8") #include "frmmain.h" -#include "qapplication.h" +#include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); + a.setFont(QFont("Microsoft Yahei", 9)); + +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif frmMain w; w.setWindowTitle("qwt无插件示例 (QQ: 517216493 WX: feiyangqingyun)"); diff --git a/third/shortcut/main.cpp b/third/shortcut/main.cpp index d85e26d..542bd47 100644 --- a/third/shortcut/main.cpp +++ b/third/shortcut/main.cpp @@ -2,12 +2,27 @@ #include "frmshortcut.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + frmShortCut w; w.setWindowTitle("全局热键示例 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/tool/keydemo/appkey.cpp b/tool/keydemo/appkey.cpp index db1e3f9..db9c24f 100644 --- a/tool/keydemo/appkey.cpp +++ b/tool/keydemo/appkey.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "appkey.h" #include "qmutex.h" #include "qfile.h" diff --git a/tool/keydemo/frmmain.cpp b/tool/keydemo/frmmain.cpp index 484df8f..5d7f060 100644 --- a/tool/keydemo/frmmain.cpp +++ b/tool/keydemo/frmmain.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "ui_frmmain.h" #include "appkey.h" diff --git a/tool/keydemo/main.cpp b/tool/keydemo/main.cpp index 7142bfd..dda6fa1 100644 --- a/tool/keydemo/main.cpp +++ b/tool/keydemo/main.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "appkey.h" #include diff --git a/tool/keytool/frmmain.cpp b/tool/keytool/frmmain.cpp index a7adbd6..3115fba 100644 --- a/tool/keytool/frmmain.cpp +++ b/tool/keytool/frmmain.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "ui_frmmain.h" #include "qmessagebox.h" diff --git a/tool/keytool/main.cpp b/tool/keytool/main.cpp index 1e96e5b..44b3dc7 100644 --- a/tool/keytool/main.cpp +++ b/tool/keytool/main.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include #include diff --git a/tool/livedemo/applive.cpp b/tool/livedemo/applive.cpp index 78495b6..71487e5 100644 --- a/tool/livedemo/applive.cpp +++ b/tool/livedemo/applive.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "applive.h" #include "qmutex.h" #include "qudpsocket.h" diff --git a/tool/livedemo/main.cpp b/tool/livedemo/main.cpp index 62dc6f3..7e9e6f1 100644 --- a/tool/livedemo/main.cpp +++ b/tool/livedemo/main.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "applive.h" #include diff --git a/tool/livetool/frmmain.cpp b/tool/livetool/frmmain.cpp index af16983..e04272b 100644 --- a/tool/livetool/frmmain.cpp +++ b/tool/livetool/frmmain.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "ui_frmmain.h" #include "qtimer.h" diff --git a/tool/livetool/main.cpp b/tool/livetool/main.cpp index 87e354c..685a7a2 100644 --- a/tool/livetool/main.cpp +++ b/tool/livetool/main.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "frmmain.h" #include "trayicon.h" #include "app.h" diff --git a/tool/moneytool/main.cpp b/tool/moneytool/main.cpp index badd9a7..86f5ee4 100644 --- a/tool/moneytool/main.cpp +++ b/tool/moneytool/main.cpp @@ -2,12 +2,27 @@ #include "widget.h" #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setFont(QFont("Microsoft Yahei", 9)); +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + Widget w; w.setWindowTitle("存款计算器 (QQ: 517216493 WX: feiyangqingyun)"); w.show(); diff --git a/tool/moneytool/widget.cpp b/tool/moneytool/widget.cpp index da6f68f..2194eea 100644 --- a/tool/moneytool/widget.cpp +++ b/tool/moneytool/widget.cpp @@ -1,4 +1,5 @@ #pragma execution_character_set("utf-8") + #include "widget.h" #include "ui_widget.h" #include "qmessagebox.h"