Issue: Transferring a class that inherits QAbstractListModel via QtRO
-
Hi all:
Has anyone used QtRO to transfer a custom ListModel implemented by inheriting QAbstractListModel? Could you please explain why the client keeps failing to initialize during the sharing process?
code://Hostmain.cpp QRemoteObjectHost host(QUrl("local:orders")); OrderModel2 *model = new OrderModel2; host.enableRemoting(static_cast<QAbstractItemModel*>(model), "OrderModel2"); //Replica.cpp QRemoteObjectNode repNode; bool ret = repNode.connectToNode(QUrl("local:orders")); qDebug() << "client connectToNode: " << ret; QAbstractItemModelReplica * replica = repNode.acquireModel("OrderModel2"); log: qt.remoteobjects: newObjects: QList(ObjectInfo("OrderModel2", "", "") ) qt.remoteobjects: connectedSources.contains( ObjectInfo("OrderModel2", "", "") ) false true qt.remoteobjects: setConnection started LocalClientIo(0x559a4be625e0) "OrderModel2" qt.remoteobjects: InitPacket--> "OrderModel2" 0x559a4be42c90 qt.remoteobjects: initialize() 2 qt.remoteobjects: Send 0 "replicaSizeRequest" 18 QList(QVariant(QList<QtPrivate::ModelIndex>, QList())) LocalClientIo(0x559a4be625e0) qt.remoteobjects: Sent InvokePacket with serial id: 1 qt.remoteobjects: isSet = true for "OrderModel2"
-
@SGaist said in Issue: Transferring a class that inherits QAbstractListModel via QtRO:
Hi and welcome to devnet,
I can't currently but: did you follow this example ?
Hi:
Thank you for your reply.
I have solved the transfer issue; it turned out I was using the wrong Function Overloading.//Hostmain.cpp QRemoteObjectHost host(QUrl("local:orders")); OrderModel2 *model = new OrderModel2; //wrong Function Overloading host.enableRemoting(static_cast<QAbstractItemModel*>(model), "OrderModel2"); //should bool QRemoteObjectHostBase::enableRemoting(QAbstractItemModel *model, const QString &name, const QList<int> roles, QItemSelectionModel *selectionModel = nullptr)
-
Oh ! Great ! Smple solution :-)
Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so other forum users may know a solution has been found :-)