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?


  • Moderators

    @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.



  • @p3c0 thx, I mean crossplatform in the way that all data will be stored on Android, iOs, Windows natively where userdata must be located. Will it be located natively?
    For example, after deinstalling app in Android, will it leave mess of user data in system?


  • Moderators

    @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.