Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Issue: Transferring a class that inherits QAbstractListModel via QtRO
Forum Updated to NodeBB v4.3 + New Features

Issue: Transferring a class that inherits QAbstractListModel via QtRO

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 104 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    big fly
    wrote last edited by
    #1

    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"
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi and welcome to devnet,

      I can't currently but: did you follow this example ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I can't currently but: did you follow this example ?

        B Offline
        B Offline
        big fly
        wrote last edited by
        #3

        @SGaist

        @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)
        
        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          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 :-)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved