Loading QML objects from C++.
-
Hi guys,
"These examples":http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.htmlI was trying to follow the instructions of Qt5.4 documentation to make QML interact with C++. I get two errors.
- D:\Qt\untitled14\main.cpp:22: error: C2661: 'QQmlProperty::QQmlProperty' : no overloaded function takes 2 arguments
2)D:\Qt\untitled14\main.cpp:22: error: C2228: left of '.write' must have class/struct/union
Any help appreciated.
//main.qml
@import QtQuick 2.0Item {
width: 100; height: 100
}@@#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQuickItem>
#include <QQmlComponent>int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);QQmlApplicationEngine engine_e; engine_e.load(QUrl(QStringLiteral("qrc:/main.qml"))); QQmlApplicationEngine engine; QQmlComponent component(&engine, QUrl::fromLocalFile(("main.qml"))); QObject *object = component.create(); object->setProperty("widh", 50); QQmlProperty(object, "width").write(80); delete object; return app.exec();
}@
Thank You.