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

C++ dynamically create objects

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 129 Views
  • 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.
  • C Offline
    C Offline
    CodeBroker
    wrote on last edited by
    #1

    Hello

    I have problems with getting C++ to create an object from an existing .qml file with pre-defined properties. I just want C++ to create it, not change any settings or what ever.

    So basically I have a button that executes createObject() when clicked. the function is supposed to create a Popup item, but nothing is appearing, and I get no errors when creating the object.

    The code inside the func:

    QQmlComponent comp(_engine, compPath);
        if (comp.status() != QQmlComponent::Ready) {
            qDebug() << comp.errorString();
            return;
        }
        auto qmlitem = comp.create();
        if (!qmlitem) {
            qDebug() << "qmlitem null";
            return;
        }
    
    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