PDA

View Full Version : How to interface between Qt/C++ and a remote Qt Quick GUI



fonzi337
31st January 2012, 21:20
Hi,

I'm working on an application that will communicate over a network. On the client side, I'd like to deploy a minimal Qt Quick GUI. I plan to write the server side in Qt/C++. As with most non-trivial Qt Quick applications, I'd like to expose some C++ functionality to the QML side; I imagine I'd probably do this by making a call to setContextProperty. The question I have is how would one go about implementing this? Is the Qt Quick engine network-aware in the sense that it knows to make callbacks over the network to a C++ object that resides on another machine?

Any direction/suggestions are appreciated. :)

wysota
31st January 2012, 21:54
You need to go over some protocol. Qt Quick can use http so if you expose a webservice, the GUI should cooperate with it. Otherwise you'll need to implement the communication in C++.

fonzi337
31st January 2012, 23:28
Thanks wysota. Would you be able to provide a really basic code example of how this can be done? What specific Qt classes and/or QML elements would I use to accomplish this?

wysota
1st February 2012, 00:18
On QML side most probably XMLListModel, on C++ client side probably QNetworkAccessManager, on C++ server side most probably QTcpServer and QTcpSocket.