Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Loading QML objects from C++.
Forum Updated to NodeBB v4.3 + New Features

Loading QML objects from C++.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 572 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Homer JS
    wrote on last edited by
    #1

    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.

    //main.qml
    @import QtQuick 2.0

    Item {
    width: 100; height: 100
    }@

    //main.cpp

    @#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&#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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved