Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to specify Qt Remote Object name in QML?



  • Hi,

    Any help would be appreciated, I'm a bit stuck with QML Qt Remote Objects. From QML I can't figure out how to connect to a specific QtRemoteObjects by remote object name also (not only by type).

    For example: I have several QtRemoteObjects of type "MyType" at "local:registry" Now, from QML I'm trying to connect to one of those remote objects called "RemoteObject4" by name. I can't figure out how or where to specify the remote object name in QML so it will return the object by name and not only type.

    The examples from the documentation just use the type, which will probably only work if there is one object of a type on that node/registry. e.g.

    MyTypeReplica {
          id: myType
          node: Node { registryUrl: "local:registry" }
     }
    

    Does anyone know where I should specify the name of the desired remote object in QML? Or isn't it supported yet and I should just use C++ for this?

    Thanks



  • After some investigation - unfortunately setNode in remoteobjects/qremoteobjectreplica.cpp doesn't pass any name parameter as a second parameter to initializeReplica(), so I guess what I want to do just isn't possible at the moment (in the current version Qt5.15).

    void QRemoteObjectReplica::setNode(QRemoteObjectNode *_node)
    {
        const QRemoteObjectNode *curNode = node();
        if (curNode) {
            qCWarning(QT_REMOTEOBJECT) << "Ignoring call to setNode as the node has already been set";
            return;
        }
        d_impl.clear();
        _node->initializeReplica(this);
    }
    

Log in to reply