Skip to content

Commit

Permalink
Use QCoreApplication replace qApp
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Mar 16, 2024
1 parent 240c652 commit 194676f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion App/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ void MainWindow::on_actionUpdate_U_triggered()

void MainWindow::on_actionExit_triggered()
{
qApp->quit();
QCoreApplication::quit();
}

void MainWindow::on_actionAiLibraries_triggered(QAction* a)
Expand Down
37 changes: 16 additions & 21 deletions App/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,42 @@
@author: Kang Lin<[email protected]>
*/

#include <QApplication>
#include <QLoggingCategory>
#if defined(Q_OS_ANDROID)
#include <QtAndroidExtras/QtAndroid>

#ifdef RABBITCOMMON
#include "RabbitCommonTools.h"
#include "RabbitCommonDir.h"
#include "FrmUpdater/FrmUpdater.h"
#endif

#include "MainWindow.h"

#ifdef RABBITCOMMON
#include "RabbitCommonTools.h"
#include "RabbitCommonDir.h"
#include "FrmUpdater/FrmUpdater.h"
#endif
#include <QApplication>

#include <QLoggingCategory>
static Q_LOGGING_CATEGORY(log, "App.main")

int main(int argc, char *argv[])
{
#if (QT_VERSION > QT_VERSION_CHECK(5,6,0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if defined(Q_OS_ANDROID) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QtAndroid::hideSplashScreen();
#endif
QApplication app(argc, argv);
app.setApplicationVersion(FaceRecognizer_VERSION);
app.setApplicationName("FaceRecognizer");

#ifdef RABBITCOMMON
qInfo(log) << "GetDirApplication:"
<< RabbitCommon::CDir::Instance()->GetDirApplication();

RabbitCommon::CTools::Instance()->Init();

QString szTranslator = RabbitCommon::CDir::Instance()->GetDirTranslations()
+ "/" + qApp->applicationName()
+ "/" + QCoreApplication::applicationName()
+ "App_" + QLocale::system().name() + ".qm";
qDebug(log) << "Translator:" << szTranslator;
QTranslator translator;
translator.load(szTranslator);
app.installTranslator(&translator);
bool bRet = translator.load(szTranslator);
if(bRet){
bRet = app.installTranslator(&translator);
if(!bRet)
qCritical(log) << "Install translator fail." << szTranslator;
}
else
qCritical(log) << "Load translator fail." << szTranslator;
#endif

app.setApplicationDisplayName(QObject::tr("Face recognizer"));
Expand Down

0 comments on commit 194676f

Please sign in to comment.