[Interest] QRemoteObject inheritance

Stottlemyer, Brett (B.S.) bstottle at ford.com
Fri May 22 13:55:39 CEST 2020


Hi Daes,

On 5/21/20, 5:15 PM, "Interest on behalf of Daesdemon" <interest-bounces at qt-project.org on behalf of daesdemon at free.fr> wrote:
    > Hello Qt people,
    It seems that QObject properties of a base classe are not exposed to 
    Replicas of Derived class.

Of course they aren't.
    
    This seems to me like a bug but i would like to have your thoughts about 
    that.

Not really.  A class can have several levels of inheritance going back to QObject.  QObject itself has several has properties, signals and slots.  E.g., `objectName` and `objectNameChagned()`.  Qt Remote Objects, behind the scenes, creates a new QObject-based type on the replica side that has the API of the original class.  But including QObject API (properties, signals and slots) doesn't make sense.  I.e., you can change the replica's name independent of the source - they shouldn't be tied together, so that shouldn't be part of the API.  So if you have inheritance, but you don't want to move up the chain all the way to QObject, where do you stop?  By default, QtRO uses just the API of a single class.

While there are several ways to modify this, the recommended approach is to create a .rep file describing the parts of the interface you want to use, and let repc generate the <Type>SourceAPI class [1] in a header.  You can then use whatever QObject you want as the source, but the templated `enableRemoting<...SourceAPI>()` call will expose the proscribed API over the Remote Objects network.
 
Regards,
Brett

[1] https://doc.qt.io/qt-5/qtremoteobjects-source.html#typeapi



More information about the Interest mailing list