#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QTranslator>
#include <QtDebug>
#include <iostream>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
std::cout << "Hello World" << locale.name().toStdString() << std::endl;
app.installTranslator(&translator);
qDebug() << "Installed translator for " << locale.name();
}
else
{
qDebug() << "Cannot load translator " << locale.name();
}
QQmlApplicationEngine engine;
const QUrl url
(QStringLiteral
("qrc:/main.qml"));
QObject::connect(&engine,
&QQmlApplicationEngine
::objectCreated,
if (!obj && url == objUrl)
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QTranslator>
#include <QtDebug>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QLocale::setDefault(QLocale::system());
QTranslator translator;
QLocale locale;
std::cout << "Hello World" << locale.name().toStdString() << std::endl;
if (translator.load(locale,QLatin1String("mockup"),QLatin1String("_"),QLatin1String(":/translations"))) {
app.installTranslator(&translator);
qDebug() << "Installed translator for " << locale.name();
}
else
{
qDebug() << "Cannot load translator " << locale.name();
}
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks