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. Accessing properties of 2D QML object in a 3DView via C++
Forum Updated to NodeBB v4.3 + New Features

Accessing properties of 2D QML object in a 3DView via C++

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

    How can I access the properties of a 2D object that is in a 3D view?

    example.qml:

    View3D {
        Node {        
            objectName: "myNodeObj",
            x: 10
            Text {
                objectName: "myTextObj",
                text: "Some text"
          }
    }
    

    I can access the properties of Node with:

    QObject *n = ui.quickWidget->rootObject()->findChild<QObject*>("myNodeObj");
    n->setProperty("x", 3);
    

    However, this doesn't work for 2D objects such as Text:

    QObject *t = ui.quickWidget->rootObject()->findChild<QObject*>("myTextObj");
    

    Returns nullptr, so I can't change the text.

    If I print out the children of Node, then rather than finding a Text object, it's been replaced with an unnamed private QQuick3DItem2D. https://doc.qt.io/qt-6/qtquick3d-architecture.html says that 2D items get wrapped in QQuick3DItem2Ds. How can they be accessed?

    Thanks.

    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