[Interest] QRemoteObjectDynamicReplica: How get a slot return value?

Stottlemyer, Brett (B.S.) bstottle at ford.com
Sat Aug 10 04:28:51 CEST 2019


Hi Daes,

Getting the pending reply from QML doesn’t currently work but is being looked at.  See QTBUG-77178.

Yeah, the documentation does need some TLC.  Patches welcome!

Regards,
Brett

From: Interest <interest-bounces at qt-project.org> on behalf of Daesdemon <daesdemon at free.fr>
Date: Friday, August 9, 2019 at 3:46 PM
To: "interest at qt-project.org" <interest at qt-project.org>
Subject: Re: [Interest] QRemoteObjectDynamicReplica: How get a slot return value?


Hi Brett,

Many thanks for the Test file link. That is really an interesting source of information. I looked in examples but not in tests.

My lone problem was I didn't know the optional Q_RETURN_ARG(QRemoteObjectPendingCall, call) required when wanted return value, and i didn't find information about a return value in the metamethod (RO seems to remove the ReturnValueType)

At my knowledge, this information is missing in documentation.

I have now everything working in C++ but how is exposed this QRemoteObjectPendingCall in QML ? with a PendingReply ?

Is there an example of that also (calling a slot with pending value on a dynamic replica from qml) ?

Cordially.

Daes

Le 08/08/2019 à 21:37, Stottlemyer, Brett (B.S.) a écrit :
Hi,

The constructor is private because you aren’t intended to create the dynamic replica directly, you must get it from a node.  The object won’t be valid until it receives an initial state from a source in another node, so the nodes must be connected together.

See: https://code.woboq.org/qt5/qtremoteobjects/src/remoteobjects/qremoteobjectnode.h.html#_ZN17QRemoteObjectNode14acquireDynamicERK7QString

Once the node is initialized, you can use Qt’s introspection methods to understand the properties, signals and slots available.
A usage example can be found in the tests, here:
https://code.woboq.org/qt5/qtremoteobjects/tests/auto/integration/tst_integration.cpp.html#_ZN15tst_Integration22slotTestDynamicReplicaEv

Using dynamica replicas is available, but is generally much more difficult than using repc.  So repc is certainly recommended for most use-cases.

Regards,
Brett

From: Interest <interest-bounces at qt-project.org><mailto:interest-bounces at qt-project.org> On Behalf Of Daesdemon
Sent: Thursday, August 8, 2019 3:03 PM
To: interest at qt-project.org<mailto:interest at qt-project.org>
Subject: [Interest] QRemoteObjectDynamicReplica: How get a slot return value?


Hi Qt people,

I have been advised to post this kind of question on the maillist instead of forum. If it is the wrong place, please, forgive me.

After digging in REPC generated code and RO sources, i found there is some "kind of magic" in the REPC code:

    - The call of returning value slot in REPC generated object use the protected sendWithReply function of QRemoteObjectReplica (async call, returning a kind of future object: QRemoteObjectPendingReply<T> with T of the ReturnType of the slot)

The problem is that the QRemoteObjectDynamicReplica have no public constructor, so no way to use this function even by derivation.

The slot signature in the dynamic replica metaobject also has no functor parameter to get the return value async. In fact the signature even loose the ReturnValue Type.

So how could  we get a slot return value from a dynamic Replica ?

If there is no way (without re-coding a large part) to do this, I find this lack of feature really troublesome in my case, where the main spec is to have no use of REPC.

A subsidiary question could be : Why is the QRemoteObjectDynamicReplica(QRemoteObjectNode *node, const QString &name) constructor private ?

If public, it would allow to overload acquireDynamic in QRemoteObjectNode and extend QRemoteObjectDynamicReplica by derivation, for, in this case, expose internally the sendAndReply function.

However the lack of the return value type would still be a problem.

I understand principle of encapsulation but i am in dead-end there.

If someone had a clue, i'll take it gratefully.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190810/3bffbf6f/attachment-0001.html>


More information about the Interest mailing list