Reading File From Asset file which is in Build folder
-
wrote on 13 Nov 2018, 07:15 last edited by Bhushan_Sure
Hello All,
As we Know After building An android project on Qt, Build file is generated in Workspace, In that Android-Build file , There is folder known as "Asset", we can move any file from any directory to this "asset folder", I am able to find that a file is present in "asset folder", But i am not able to read it through "Qfile", can anybody knows how to read it ?code i have written for reading file :-
void AssetFileDisplay::displaytext() { QFile dfile("assets:/Add.txt"); if (dfile.exists()) { qDebug()<<"Ready to Go"; } QTextStream in(&dfile); QString line = in.readLine(); emit complete(line); }
-
Hello All,
As we Know After building An android project on Qt, Build file is generated in Workspace, In that Android-Build file , There is folder known as "Asset", we can move any file from any directory to this "asset folder", I am able to find that a file is present in "asset folder", But i am not able to read it through "Qfile", can anybody knows how to read it ?code i have written for reading file :-
void AssetFileDisplay::displaytext() { QFile dfile("assets:/Add.txt"); if (dfile.exists()) { qDebug()<<"Ready to Go"; } QTextStream in(&dfile); QString line = in.readLine(); emit complete(line); }
@Bhushan_Sure
a general question,are you aware of Qt's platform independed ressource system ? http://doc.qt.io/qt-5/resources.html
From this and your last topic, I think you may not be aware of it's existence. -
wrote on 13 Nov 2018, 08:00 last edited by
You haven't opened the file before trying to open the stream,
-
wrote on 13 Nov 2018, 09:08 last edited by
@mvuori You are right, Thank you very much.
@J-Hilk Thank you, For some new suggestions, i would like implement this. :)
1/4