Transferring data between two QtQuick apps and local storage
-
Hi all,
I've got two questions.- If we want to create two qml apps named clientApp and serverApp running at the same time so that we can send messages from the client to the server app, is the following route correct to pass, please?
In the server app:
we firstly provide an IP address and port number. Then using aQDataStream in
try to get the message sent from the client app and set it to a label.In the client app:
we find all the ip addresses and among them select the one shown by the server already plus a port. Then define aQDataStream out
to send a message to the server app.- Since Qt Quick offers only limited ways of storing local data directly, and in this sense, it acts more like a browser and in many projects storing data is handled by the C++ backend and the required functionality is exported to the Qt Quick frontend side, (from Qt QML 6 book), if we have a
Qmap<QString,QString>
, how to store and retrieve it to/from local storage at the back-end part (C++), please?
-
Hi,
Are these two applications running on the same machine ?
If so write your backend to use QLocalSocket/QLocalServer and if not QTcpSocket/QTcpServer. I don't see a reason to store anything on disk in between.
-
Yes, the apps run on the same machine but I'd like to use QTcpSocket/QTcpServer not just to handle that functionality but this way also to get started learning using them practically. Now is the scenario (described in #1) right, please?
As for storing data on secondary memory/disk, I need it for another QtQuick project where it's required to store data in a QMap and then be able to retrieve them when needed. What method do you suggest to be used at the back-end for that purpose, please?
-
Both can be drop in replacement for each other so you can start locally and once you have everything running for the client server part, you can add networking.
Can you explain how that secondary application is supposed to work ? Reading and writing to a file from two different application has its own challenge in terms of synchronisation.
-
Probably I should have posted the question #2 in another thread, but I though the answer would be simple so asked that also here alongside the question about networking.
Anyway, let's get it straight and as simple as possible. You have a qml app running on , say, an Android device. The user adds some elements at the front-end. Each element consists of a name and some texture description. In the back-end, we use a QMap<QString,QString> to store data into. Then the user exits the app and tomorrow re-runs it. He should be able to see the data saved in the back-end yesterday.
I hope it's now clear.