Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Store/Display images to/from SQLite

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #19701

    Eric

    Hello,

     

    I’m pretty new to QML and have never learned C++. Since my app is pretty simple (no heavy calculations necessary), I’ve been using only Javascript. However, I can’t find anything online about using Javascript to store images to a database and retrieving them. Since users of my app at some point may want to add an image to a part of the app, I thought I should let them choose the image then store it as a BLOB in the SQLite database, so if the image is removed from their device at a later time, it will still be available to the app. Is storing the image as a BLOB appropriate? Or is it possible to store it another way?

     

    Once the image is stored, how can it be retrieved? Is C++ necessary or is there a way to use Javascript only?

     

    I see the component in Felgo’s ‘Showcase’ app that loads images but how then can I store them so the user has access even when offline or if he deletes the image from his device?

     

    Thank you for your help,

    Eric

    #19704

    Alex
    Felgo Team

    Hi Eric,

    working with the image data directly in JavaScript can be a bit troublesome at times, as you need the actual ByteArray, that’s where I would suggest a bit of C++.

    2 options come to my mind right away:

    • Copy the image to the application data location. You can do this with the FileUtils. See: FileUtils::copyFile, FileUtils::AppDataLocation
    • Another option would be your BLOB-like solution. We’ve created a small example for a customer some time ago, which reads an image taken with the camera and encodes the image data as base64. This data could then be stored in a database or one of the other storage options with Felgo. The base64 image data can be used directly with any image item in QML. I’ll send you the example as an email.

    Cheers,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.