Changes to Qt Remote Objects

Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.

We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework.

In this topic we summarize those changes in Qt Remote Objects, and provide guidance to handle them.

API changes

Functions taking const-ref QString changing to QStringView

QRemoteObjectHostBase::proxy, QRemoteObjectHostBase::reverseProxy and QRemoteObjectNode::instances now accept a QStringView instead of const QString &. The largest difference caused by this is that it no longer accepts implicit conversion from string literals (i.e. node.instances("abc");). Instead, you could use a UTF-16 string literal (node.instances(u"abc")).

Changes to classes for custom transport backend support

The "semi-private" IoDeviceBase, ServerIoDevice, and ClientIoDevice classes are now renamed to QtROIoDeviceBase, QtROServerIoDevice, and QtROClientIoDevice respectively, to be consistent with naming in Qt. They are also moved from the private qconnectionfactories_p.h header to qconnectionfactories.h.

Note: These classes are provided to give more flexibility for implementing custom communication protocols for Qt Remote Objects, but there are no source or binary compatibility guarantees for them. We recommend using the QRemoteObjectNode::addClientSideConnection() and QRemoteObjectHostBase::addHostSideConnection() methods, if you need support for external communication channels.

CMake changes

The cmake instructions for calling repc and adding the generated .rep files to a CMake project have slightly changed. Instead of the qt5_generate_repc macro, you should now use qt6_add_repc_sources, qt6_add_repc_replicas and qt6_add_repc_merged functions. For example, the following code:

set(SOURCES
    main.cpp
    simpleswitch.cpp
)

qt5_generate_repc(SOURCES simpleswitch.rep SOURCE)
add_executable(directconnectserver ${SOURCES})

Should change to:

set(SOURCES
    main.cpp
    simpleswitch.cpp
)
add_executable(directconnectserver ${SOURCES})
qt6_add_repc_sources(directconnectserver simpleswitch.rep)

More detailed descriptions for these CMake functions can be found here.

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.