Local storage. Approach [SOLVED]
-
Hi guys.
I am writing a crossplatform QtQuick application which has QML Front-end (view) and C++ back-end (model).
I am picking up an approach to store local user data crossplatform way. So far I found that there is example of implementing Local Storage with QML.
However my QML (MVC template) is considered only as View functionality, moreover, all data models are implemented with C++.
Shall I use C++ for realizing Local Storage? If yes, where to get example to make it crossplatform. Or It is fine practice to use QML? -
@Kofr Since you are using C++ models
Shall I use C++ for realizing Local Storage?
Yes.
If yes, where to get example to make it crossplatform.
Since Qt has inbuilt support for SQLite it will automatically be crossplatform. You can follow this example and specifically follow Connecting to a Database topic.
Or It is fine practice to use QML?
Since you are using QML/Javascript only for view its better to do with C++ as the model can integrate with it easily.
-
-
@Kofr Leave it to Qt to figure out the paths i.e use QStandardPaths. See QStandardPaths::writableLocation and QStandardPaths::standardLocations. Preferably use QStandardPaths::AppDataLocation as
StandardLocation
. I think in android after the user uninstalls the app his data too erases.