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. Where is my file
Forum Updated to NodeBB v4.3 + New Features

Where is my file

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 3 Posters 1.7k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    kgregory
    wrote on last edited by
    #1

    I have a custom read-only file containing some data that I need to open in my mobile app. I added it as a resource and it shows up in the "other files" section of resources. How do I get the path to this file on the device?

    K 1 Reply Last reply
    0
    • K kgregory

      I have a custom read-only file containing some data that I need to open in my mobile app. I added it as a resource and it shows up in the "other files" section of resources. How do I get the path to this file on the device?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @kgregory

      Did you checkout the documentation to compiled in resources?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kgregory
        wrote on last edited by
        #3

        @koahnig

        This is helpful, although I'm not sure I understand all of the terminology. Is it saying that all of the resources are compressed inside of my excecutable binary? If so, how do I put it into the ordinary file system? Is that what the external binary resources section is about?

        My challenge is that I'm trying to integrate some C code that I got from another source, which is not built on Qt, and it requires a full canonical path to the file. After reading this article, I was able to locate the file using QFile. But when I tried obtaining the canonical path using the code below, it simply expands as ":/myFile.dat".

        QDir localdir("://");
        QString myfile = localdir.canonicalPath();
        myfile.append("myFile.dat");
        
        K 1 Reply Last reply
        0
        • K kgregory

          @koahnig

          This is helpful, although I'm not sure I understand all of the terminology. Is it saying that all of the resources are compressed inside of my excecutable binary? If so, how do I put it into the ordinary file system? Is that what the external binary resources section is about?

          My challenge is that I'm trying to integrate some C code that I got from another source, which is not built on Qt, and it requires a full canonical path to the file. After reading this article, I was able to locate the file using QFile. But when I tried obtaining the canonical path using the code below, it simply expands as ":/myFile.dat".

          QDir localdir("://");
          QString myfile = localdir.canonicalPath();
          myfile.append("myFile.dat");
          
          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @kgregory said in Where is my file:

          @koahnig

          This is helpful, although I'm not sure I understand all of the terminology. Is it saying that all of the resources are compressed inside of my excecutable binary? If so, how do I put it into the ordinary file system? Is that what the external binary resources section is about?

          An resource I would simply use for smaller dataset, since it is part of your executable. I have never worked with external resource files.

          @kgregory said in Where is my file:

          My challenge is that I'm trying to integrate some C code that I got from another source, which is not built on Qt, and it requires a full canonical path to the file. After reading this article, I was able to locate the file using QFile. But when I tried obtaining the canonical path using the code below, it simply expands as ":/myFile.dat".

          QDir localdir("://");
          QString myfile = localdir.canonicalPath();
          myfile.append("myFile.dat");
          

          Most likely there are other issues arising when you try make your internal resources accessible for other code. What you could do is reading the internal resource and storing it, perhaps on temporary space, somewhere.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          1
          • Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @kgregory Are you sure you really need to deploy the read-only file as part of your application binary? that's what's happening when you create a resource file in Qt, all the items added to the resource file are "embedded" in your executable file. A resource file is mostly intended for items such as icons, little images for buttons, translation files, so having just them inside your binary file saves headaches on deployment.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              As a follow up, if you cannot deploy your read-only file as a separate item and it will end up as part of the resource file, you can read it like this:

              QFile file(":/myFile.dat");
              

              Please read again the documentation about resources pointed out in previous post.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kgregory
                wrote on last edited by
                #7

                OK, I wound up putting it in the the resource file and then copying it to a temporary location before it is needed. This appears to work.

                On to new problems now...

                1 Reply Last reply
                0

                • Login

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