Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Unable to connect QML Remote Object with error "connectionToSource is null"

    QML and Qt Quick
    1
    1
    301
    Loading More Posts
    • 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.
    • J
      jay1 last edited by jay1

      I am trying to use Qt Remote Objects for creating client server application.
      But encountered an issue that says "connectionToSource is null". How do I set the source connection ?

      I am creating the server using the .rep file. The code I had used is as follows:

      Server Code

      // DataBroadcaster class inherits CustomModelSimpleSource.h (generated from .rep file)
      DataBroadcaster dataServer;
      QRemoteObjectHost host;
      host.setHostUrl(QUrl(QStringLiteral("local:mydata")));
      host.enableRemoting(&dataServer, "MyDataTag");
      

      Client Code

      // CustomModelDataReplica is generated from .rep file used to generate source
      // registered as qml type in main
      qmlRegisterType<CustomModelDataReplica>("CustomData", 1, 0, "MyData");
      

      // Added to QML file

      import CustomData 1.0
      
      MyData {
      	id: dataClient
      	node: Node {
      		registerUrl: "local:mydata"
      	}
      	Button {
      		id: btn
      		text: "Server Data" 
      		onClicked: {
      			// displaying some data from source
      			btn.text = dataClient.myprop
      		}
      	}
      }
      

      Execution:

      Server code is running
      Client code is running but when trying to get data I get following error message in debugger
      **"qt.remoteobjects: connectionToSource is null"**
      

      I am unable to figure out what am I missing.
      If anyone has any idea about how to resolve or where to look for please suggest.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post