Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Reading File From Asset file which is in Build folder
Forum Updated to NodeBB v4.3 + New Features

Reading File From Asset file which is in Build folder

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 808 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bhushan_Sure
    wrote on 13 Nov 2018, 07:15 last edited by Bhushan_Sure
    #1

    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);
    }
    
    J 1 Reply Last reply 13 Nov 2018, 07:19
    0
    • B Bhushan_Sure
      13 Nov 2018, 07:15

      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);
      }
      
      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 13 Nov 2018, 07:19 last edited by
      #2

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


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        mvuori
        wrote on 13 Nov 2018, 08:00 last edited by
        #3

        You haven't opened the file before trying to open the stream,

        B 1 Reply Last reply 13 Nov 2018, 09:08
        4
        • M mvuori
          13 Nov 2018, 08:00

          You haven't opened the file before trying to open the stream,

          B Offline
          B Offline
          Bhushan_Sure
          wrote on 13 Nov 2018, 09:08 last edited by
          #4

          @mvuori You are right, Thank you very much.
          @J-Hilk Thank you, For some new suggestions, i would like implement this. :)

          1 Reply Last reply
          0

          1/4

          13 Nov 2018, 07:15

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved