Loading QML objects from C++.

  • Hi guys,
    "These examples":http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html

    I was trying to follow the instructions of Qt5.4 documentation to make QML interact with C++. I get two errors.

    1. 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.

    @import QtQuick 2.0

    Item {
    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;
    QQmlApplicationEngine engine;
    QQmlComponent component(&engine, QUrl::fromLocalFile&#40;("main.qml"&#41;&#41;);
    QObject *object = component.create();
    object->setProperty("widh", 50);
    QQmlProperty(object, "width").write(80);
    delete object;
    return app.exec&#40;&#41;;


    Thank You.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.