My app require reading contents from a file. Can you do it using QML alone? Or should I use C++ for it ?
File i/o in c++
You can read local text files using XMLHttpRequest in QML. However, this lacks all of the features of XMLHttpRequest2 and some of the of version 1, which makes it impossible, as far as I can tell, to read in binary files.
To get around this, I wrote a C++ plugin for QML for reading files. It still can't work with binary files directly, but it gives an option of reading them in base64 encoding. I've released this code into the public domain, so do with it what you will.
There is built-in file I/O available for QML with the V-Play SDK FileUtils. It works cross-platform on desktop, iOS and Android.
It looks like this:
var documentsData = fileUtils.readFile("subfolder/file.json")