parent
828e0ba144
commit
6bd460f88c
Binary file not shown.
@ -1,20 +1,28 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <QQmlContext>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QDebug>
|
||||||
#include "myclass.h"
|
#include "myclass.h"
|
||||||
//#include <QDebug>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
// Localization
|
||||||
|
QString locale = QLocale::system().name();
|
||||||
|
qDebug() << "Locale: " + locale;
|
||||||
|
|
||||||
|
QTranslator translator;
|
||||||
|
translator.load("2048-qt_" + locale);
|
||||||
|
app.installTranslator(&translator);
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
||||||
|
|
||||||
MyClass myClass;
|
MyClass myClass;
|
||||||
|
// Access C++ object "myClass" from QML as "myClass"
|
||||||
// qDebug() << engine.rootObjects().length();
|
engine.rootContext()->setContextProperty("myClass", &myClass);
|
||||||
QObject *mainWindow = engine.rootObjects()[0];
|
|
||||||
QObject::connect(mainWindow, SIGNAL(helpMenuTriggered()), &myClass, SLOT(aboutQt()));
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue