Put c++ data to QML the first time: YEAAAAHHHH ;-)

This commit is contained in:
Felix Hammer
2015-08-13 22:36:11 +02:00
parent 93b9881e75
commit ee897f17ef
8 changed files with 66 additions and 47 deletions
+4 -2
View File
@@ -1,18 +1,20 @@
#include <QtCore>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <configfile.h>
#include <boost/shared_ptr.hpp>
#include "qmlconfig.h"
#include "qmlwrapper.h"
QmlWrapper::QmlWrapper(boost::shared_ptr<ConfigFile> c)
:QObject(), myConfig(c)
{
qDebug("QmlWrapperKonstruktor");
myEngine.reset(new QQmlApplicationEngine);
myQmlConfig = new QmlConfig(myConfig); //need to be a default pointer because QML doesnt support shared_ptr()
// Add c++ content here
// myEngine.rootContext()->setContextProperty("model1", &model1);
myEngine->rootContext()->setContextProperty("Config", myQmlConfig);
myEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
}