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. get canonical path?
Qt 6.11 is out! See what's new in the release blog

get canonical path?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
12 Posts 3 Posters 4.8k 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

    Is there a QT library/object/method to obtain the canonical path to the local directory?

    Also, are there any tips for expressing file paths that will be understood on both Android and iOS?

    raven-worxR 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you thinking about QDir::canonicalPath ?

      What local directory do you have in mind ? What for ?

      For cross-platform path handling, take a look at QStandardPaths.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • K kgregory

        Is there a QT library/object/method to obtain the canonical path to the local directory?

        Also, are there any tips for expressing file paths that will be understood on both Android and iOS?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @kgregory said in get canonical path?:

        Is there a QT library/object/method to obtain the canonical path to the local directory?

        you mean QDir::canonicalPath()?
        What local directory do you mean?

        Also, are there any tips for expressing file paths that will be understood on both Android and iOS?

        Understood just by your app? If so you could use something like %HOME%/path/to/somewhere and replace the %HOME% with the a Qt standard path
        You will have to check if the standard locations return meaningful paths on both systems for you.

        Edit: @SGaist
        lol, exactly the same thoughts ^^

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

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

          I have a file that I plan to distribute with my app. I want to open the file with an API that I've obtained and the API says it requires the full canonical path. Therefore, I need the app to be able to find the full canonical path to the directory where my file is installed.

          QDir::canonicalPath() will be useful, but I think I first need to know the path to the installation directory.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Where do you expect to store that file ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

              I'll put it in the same directory with the app, or perhaps I'll move it to a subdirectory.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                If you intend to modify that file, use QStandardPath to retrieve a writable location. Neither iOS nor Android allow modification in the application folders.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                  That's odd. I've had a file that the app creates to store app data and have had no problem reading & writing it. I've supplied only a relative path in that case, though.

                  In this case, the API I'm integrating requries the full canonical path. Also, in this case, the file is read only.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    You can't compare developing on your machine and running your application on a mobile device. Your technique will work on your machine because you are launching your application from a folder you have the rights to read from and write to. That won't be the case on your phone, tablet, etc.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                      No, it is on my phone. Or are you are saying that my phone has special rights because it's in debug mode?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        You can read files within your application bundle, no problem with that. What you can't do is write them there.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                          I'm not sure where it's writing the file (I didn't provide any path). It is persistent and my app always finds it, so it's accomplished what I set out for it to do.
                          Perhaps it won't work when I try running this on iOS, in which case I'll have to give it more thought.

                          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